IIS 7 站点设置支持url_rewrite

站点从2003 的IIS6 迁移到 2008的IIS7发现web.config里面配置的URL_Rewrite不生效,也查了好久,先贴下配置文件

<configSections>
        <!-- 地址重写配置 -->
        <section name="RewriterConfig" type="URLRewriter.Config.RewriterConfigSerializerSectionHandler, URLRewriter" />
        <!--日志记录-->
        <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" />
    </configSections>
    <RewriterConfig>
        <Rules>
            <!--重写规则 -->
            <!--<RewriterRule>
                <LookFor>~/(.[0-9]*)</LookFor>
                <SendTo>~/v2/play.html?roomid=$1</SendTo>
            </RewriterRule>-->      
            <RewriterRule>
        <LookFor>~/(d+)</LookFor>
        <SendTo>~/v5/player.aspx?roomid=$1</SendTo>
      </RewriterRule>
            <RewriterRule>
                <LookFor>~/jy/(w+)</LookFor>
                <SendTo>~/jy/play.aspx?roomid=$1</SendTo>
            </RewriterRule>
      <RewriterRule>
        <LookFor>~/user/(.[0-9]*)</LookFor>
        <SendTo>~/v4/userspace.aspx?uidx=$1</SendTo>
      </RewriterRule>
      <!--<RewriterRule>
        <LookFor>~/room/(.[0-9]*)-(.[0-9]*).html</LookFor>
        <SendTo>~/v2/roomlist_v.aspx?sid=$1&amp;serverid=$2</SendTo>
      </RewriterRule>-->
      <!--<RewriterRule>
        <LookFor>~/room/(.[0-9]*)-(.[0-9]*).html</LookFor>
        <SendTo>~/v2/roomlist_v.aspx?sid=$1&amp;serverid=$2</SendTo>
      </RewriterRule>-->
      <RewriterRule>
        <LookFor>~/room/list-(.[0-9]*)-(.[0-9]*).html</LookFor>
        <SendTo>~/v5/roomList.aspx?dq_id=$1&amp;id=$2</SendTo>
       </RewriterRule>
      <RewriterRule>
        <LookFor>~/m(d+)</LookFor>
        <SendTo>~/v6/player.aspx?useridx=$1</SendTo>
      </RewriterRule>
       </Rules>
    </RewriterConfig>

只需要进行简单的配置就可以生效

 

记录一下,以防下次再忘记了

原文地址:https://www.cnblogs.com/LouisZJ/p/8580023.html