1.在web.config文件中 <configuration>节点的<configSections>下面的配置节点
<!--配置重写规则节点--> <section name="RewriterConfig" type="URLRewriter.Config.RewriterConfigSerializerSectionHandler, URLRewriter" />
2.在 <configuration>节点范围类编写重写规则
<!--重写规则--> <RewriterConfig> <Rules> <RewriterRule> <LookFor>~/web/new/(.[0-9]*)/.aspx</LookFor> <SendTo>~/web/new.aspx?id=$1</SendTo> </RewriterRule> <RewriterRule> <LookFor>~/index.html</LookFor> <SendTo>~/default.aspx</SendTo> </RewriterRule> <RewriterRule> <LookFor>~/show_([0-9]*).html</LookFor> <SendTo>~/show.aspx?id=$1</SendTo> </RewriterRule> </Rules> </RewriterConfig>
3.在 <system.web>节点中的 <httpHandlers>下面配置
<add verb="*" path="*.aspx" type="URLRewriter.RewriterFactoryHandler, URLRewriter" /> <add verb="*" path="*.html" type="URLRewriter.RewriterFactoryHandler, URLRewriter" /><!--不加此节点不能定向html页面-->
4.在浏览器中输入 index.html,实际访问的是default.aspx页面
访问show_2.html实际是访问show.aspx?id=2的页面
新闻热点
疑难解答