Intelligencia.UrlRewriter.dll aspx重写为html实例

时间:2015/12/1 10:15:00来源:互联网 作者:flyso 点击: 1307 次

1、http://urlrewriter.net/  下载解压缩后把Intelligencia.UrlRewriter.dll 文件添加引用到web工程里。

2.web.config配置:

<configSections>
  <!--UrlRewriter-->
  <section name="rewriter" requirePermission="false" type="Intelligencia.UrlRewriter.Configuration.RewriterConfigurationSectionHandler, Intelligencia.UrlRewriter" />
< /configSections>

< system.web>
  <!--UrlRewriter-->
  <httpModules>
   <add type="Intelligencia.UrlRewriter.RewriterHttpModule,Intelligencia.UrlRewriter" name="UrlRewriter" />
        </httpModules>
< /system.web>
< /system.web>

< !--UrlRewriter-->
< rewriter>
  <rewrite url="~/test_([a-zA-Z]+).html$" to="~/Show.aspx?Code=$1" processing="stop" />
< /rewriter>

其中: <rewrite url="~/test_([a-zA-Z]+).html$" to="~/Show.aspx?Code=$1" processing="stop" />

若果code= abc的话,最终显示的结果为"虚拟目录名称/test_abc.html" 。如果吧.html替换成 .aspx那就是"虚拟目录名称/test_abc.aspx"

3.IIS配置:
如果是用"虚拟目录名称/test_abc.aspx" 的话,不需要配置IIS. 使用了"虚拟目录名称/test_abc.html" 配置IIS的方法如下:
http://urlrewriter.net/index.php/support/installation/windows-server-2003/ 里面的图9不准确,准确的为:



还有第八步中的”untick Verify that file exists.“要看仔细。否则重写HTML就无效。

c:\windows\microsoft.net\framework\v2.0.50727\aspnet_isapi.dll

4:备注

不要在"应用程序扩展"里“添加" .html的映射,否则正常的html将无法访问。

Copyright © 2005 - 2016 flyso.cn. 飞搜 版权所有 鄂ICP备11002783号-3