复制代码 代码如下:
<?xml version= encoding=UTF?>
<configuration>
<!第一步注册url重写模块放到webconfig的最上部>
<configSections>
<section name=RewriterConfig type=URLRewriterConfigRewriterConfigSerializerSectionHandler URLRewriter />
</configSections>
<!第二步添加重写规则>
<RewriterConfig>
<!先制定全部重写规则内容>
<Rules>
<!制定每个单独页面的规则>
<RewriterRule>
<!原始请求地址>
<SendTo><![CDATA[~/newsaspx?id=$&pid=$]]></SendTo>
<!重写后的地址>
<LookFor>~/news/([]*)/([\d]*)l</LookFor>
</RewriterRule>
<RewriterRule>
<!原始请求地址>
<SendTo><![CDATA[~/productaspx?pid=$]]></SendTo>
<!重写后的地址>
<LookFor>~/product/([\d]*)\zangdalei</LookFor>
</RewriterRule>
</Rules>
</RewriterConfig>
<systemweb>
<compilation debug=false targetFramework=>
<!第四部url重写防止真实的页面也被重写如果网站中真实存在页面需要添加编译指令不编译真实的html文件>
<buildProviders>
<add extension=l type=SystemWebCompilationPageBuildProvider />
</buildProviders>
</compilation>
<!第三部url重写 将用户的请求页面交给相应的处理程序注意请求的后缀名格式>
<httpHandlers>
<add verb=* path=l type=URLRewriterRewriterFactoryHandler URLRewriter />
<add verb=* path=*zangdalei type=URLRewriterRewriterFactoryHandler URLRewriter />
</httpHandlers>
</systemweb>
<systemwebServer>
<handlers>
<add name=aspnethtml path=l verb=GETPOST modules=IsapiModule scriptProcessor=C:\Windows\MicrosoftNET\Framework\v\aspnet_isapidll resourceType=Unspecified preCondition=classicModeruntimeVersionvbitness />
<add name=aspnetzangdalei path=*zangdalei verb=GETPOST modules=IsapiModule scriptProcessor=C:\Windows\MicrosoftNET\Framework\v\aspnet_isapidll resourceType=Unspecified preCondition=classicModeruntimeVersionvbitness />
</handlers>
<defaultDocument>
<files>
<clear />
<add value=defaultaspx />
<add value=l />
</files>
</defaultDocument>
</systemwebServer>
</configuration>