zoukankan      html  css  js  c++  java
  • .net的URL重定向的配置

    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&amp;topic=$1</SendTo><!--多个参数用 &amp; 代替&-->
          </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

  • 相关阅读:
    html例题——简历
    求值
    c#语句实例(排大小)
    3.6语言基础笔记
    2016.3.5进制间的转换
    3.26-1
    3.23(网页)
    3.23
    3.22
    3.20
  • 原文地址:https://www.cnblogs.com/skybreak/p/3043027.html
Copyright © 2011-2022 走看看