asp.net url重写实现伪静态方法
把附件中的dll放到bin目录,web.config配置文件如下:
(1) <configuration>节下加
<configSections>
<section name="RewriterConfig" type="UrlRewriter.Config.RewriterConfigSerializerSectionHandler, UrlRewriter"/>
</configSections>
(2) IIS 6.0在 <system.web>节下加
<httpModules>
<add name="RewriterModule" type="UrlRewriter.RewriterModule, UrlRewriter"/>
</httpModules>
IIS 7.0以上在<system.webServer>节下加
<modules>
<add name="RewriterModule" type="UrlRewriter.RewriterModule, UrlRewriter"/>
</modules>
(3)<configuration>节下,配置Url重写规则,使用正则匹配的方式,例子如下:
<RewriterConfig>
<Rules>
<RewriterRule>
<LookFor>~/c(\d+)-t(\d+).html</LookFor>
<SendTo>~/List.aspx?ChannelID=$1&TypeID=$2</SendTo>
</RewriterRule>
</RewriterConfig>
例如请求url :c1-t2.html 会重写到 List.aspx?ChannelID=1&TypeID=2
2023-07-25 广告