日期:2014-05-18  浏览次数:20411 次

实现地址重写 如www.xxx.com/?from=nva
如何实现地址栏的重写

效果如下

www.xxx.com/?from=nva



------解决方案--------------------
下载个 Mircosoft 的 URLRewriter.dll ,添加引用后配置web.config如下,重写规则的正则表达式你再改下:
XML code


<?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>~/web/index.html</LookFor>
        <SendTo>~/web/index.aspx</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>