zoukankan      html  css  js  c++  java
  • 利用Intelligencia.UrlRewriter.dll实现URL重写

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

    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就无效。

    4:备注

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

    5.在vs2005中,传多个参数应该加&amp;在vs2003中,只用分号就好了

    eg.

    <RewriterConfig>
        <Rules>
          <RewriterRule>
            <!--CreditNews BackGround update-->
            <LookFor>~NewsClsManage-(\d*)-(\d*).html</LookFor>
            <SendTo>~NewsClsManage.aspx?ClassID=$1&amp;flag=$2</SendTo>
          </RewriterRule>
        </Rules>
    </RewriterConfig>


  • 相关阅读:
    Linux 常用命令
    silky微服务简介
    okhttp中的Builder模式
    Assert in C#&Java
    Abstract类中使用@Autowire
    @Scope("prototype") bean scope not creating new bean
    【转】centos系统查看cpu内存等情况
    hdu 7013 String Mod 题解
    牛客 11259 H Scholomance Academy 题解
    bzoj 2151 种树 题解
  • 原文地址:https://www.cnblogs.com/qq4004229/p/2158107.html
Copyright © 2011-2022 走看看