通过module实现url重写

  通过module实现url重写,url重写是把一个复杂的链接变得简单,把一个动态的链接变得看起来是静态文件,比如把news.aspx?id=99 变成news/99.html这样,方便记忆。目前网络上有一部分看起来是静态的网络,实际上后台都是动态的。这样访问news/99.html文件的时候,实际访问的news.aspx?id=99。 n当然,实际做项目的时候,一般是使用现成的重写组件,比如:著名的开源重写组件Intelligencia.UrlRewriter。http://urlrewriter.net/这就是一个httpmodule。 n这个组件的配置如下:在<configSections>添加如下的节点 <section requirePermission="false" type="Intelligencia.UrlRewriter.Configuration.RewriterConfigurationSectionHandler, Intelligencia.UrlRewriter"/> n在modu添加: <add/> n添加url重写规则 <rewriter>         <rewrite url="~/News/View.html$" to="~/Lists.aspx?order=view" processing="stop"/>         <rewrite url="~/News/(.+).html$" to="~/News.aspx?ID=$1" processing="stop"/>         <rewrite url="~/Titles/(.+).html$" to="~/Lists.aspx?Title=$1"/>         <rewrite url="~/default.html$" to="~/default.aspx"/>         <rewrite url="~/Rss.xml$" to="~/rss.aspx"/>     </rewriter> IIS配置参考http://www.cnblogs.com/songsgroup/archive/2009/02/11/1388506.html

posted @ 2010-06-29 11:15  爱国者  阅读(338)  评论(0编辑  收藏  举报