UrlReWriter实现

引用 http://urlrewriter.net的源代码实现UrlReWriter;建议大家不要去官方网站下载了,到处都是google ads 的广告,估计写代码的那哥们穷疯了。

这个不需要IIS上配置,引用相关dll后只要在web.config中配置即可。配置代码:

<? xml version = " 1.0 " ?>
< configuration >
  
< configSections >
    
< section
            name
= " rewriter "
            type
= " Intelligencia.UrlRewriter.Configuration.RewriterConfigurationSectionHandler, Intelligencia.UrlRewriter "   />
  
</ configSections >
  
< rewriter >
    
< register logger = " Intelligencia.UrlRewriter.Logging.DebugLogger, Intelligencia.UrlRewriter "   />
    
< if  url = " ~/tags/(.+) "  rewrite = " ~/tagcloud.aspx?tag=$1 "   />
    
< if  url = " ~/test "  rewrite = " ~/tagcloud.aspx?tag=1 "   />
    
<!--  same thing  as   < rewrite url = " /tags/(.+) "  to = " /tagcloud.aspx?tag=$1 "   />   -->
  
</ rewriter >
  
< appSettings />
  
< connectionStrings />
  
< system.web >
    
< httpModules >
      
< add
                type
= " Intelligencia.UrlRewriter.RewriterHttpModule, Intelligencia.UrlRewriter "
                name
= " UrlRewriter "   />
    
</ httpModules >
    
< compilation debug = " false "   />
  
</ system.web >
</ configuration >

dll最好使用release版本的。

你可能感兴趣的:(urlrewrite)