1,首先引入dll文件(URLRewriter.dll):
这个可以在网上找,不过千万注意版本。该dll选择那个20K的版本,比这个小的是不全的,配置的时候会出错。
2,配置web.config:
<?xml version="1.0"?> <configuration> <configSections> <section name="RewriterConfig" type="URLRewriter.Config.RewriterConfigSerializerSectionHandler, URLRewriter" /> </configSections> <RewriterConfig> <Rules> <RewriterRule> <LookFor>~/web/new/type/(.[0-9]*)/.html</LookFor> <SendTo>~/web/new.aspx?id=$1</SendTo> </RewriterRule> <RewriterRule> <LookFor>~/index.html</LookFor> <SendTo>~/index.aspx</SendTo> </RewriterRule> <RewriterRule> <LookFor>~/KanPage-(\w+)-(\d+).html</LookFor> <SendTo>~/KanPage.aspx?Id=$2&topic=$1</SendTo><!--多个参数用 & 代替&--> </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"/> </system.web> </configuration>
这样就O了!
URLRewriter下载:https://files.cnblogs.com/skybreak/URLRewriter.zip