首页 > 代码库 > 使用微软URLRewriter.dll的url实现任意后缀名重写
使用微软URLRewriter.dll的url实现任意后缀名重写
<?xml version="1.0"?> <!--先引用URLRewriter.dll,放置于Bin目录--> <configuration> <configSections> <!--配置重写规则节点--> <section name="RewriterConfig" type="URLRewriter.Config.RewriterConfigSerializerSectionHandler, URLRewriter"/> </configSections> <connectionStrings> <add name="TestConnectionString" connectionString="Data Source=.;Initial Catalog=Test;Integrated Security=True" providerName="System.Data.SqlClient"/> </connectionStrings> <!--重写规则--> <RewriterConfig> <Rules> <RewriterRule> <LookFor>~/product/([0-9]*)\.html</LookFor> <!--http://www.xxx.com/product/8001.html--> <SendTo>~/product.aspx?pid=$1</SendTo> <!--http://www.xxx.com/product.aspx?pid=8001--> </RewriterRule> <RewriterRule> <LookFor>~/product/([0-9]*)-([0-9]*)\.html</LookFor> <!--http://www.xxx.com/product/101-8001.html--> <SendTo>~/product.aspx?sid=$1&pid=$2</SendTo> <!--http://www.xxx.com/product.aspx?sid=101&pid=8001--> </RewriterRule> <RewriterRule> <LookFor>~/product/([0-9]*)/([0-9]*)\.html</LookFor> <!--http://www.xxx.com/product/101/8001.html--> <SendTo>~/product.aspx?sid=$1&pid=$2</SendTo> <!--http://www.xxx.com/product.aspx?sid=101&pid=8001--> </RewriterRule> </Rules> </RewriterConfig> <system.web> <httpHandlers> <add verb="*" path="*.aspx" type="URLRewriter.RewriterFactoryHandler, URLRewriter"/> <add verb="*" path="*.html" type="URLRewriter.RewriterFactoryHandler, URLRewriter"/> </httpHandlers> <compilation debug="true" targetFramework="4.0"/> </system.web> </configuration>
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。