使用Intelligencia.UrlRewriter将www子域重定向到根域

时间:2011-03-05 15:41:00

标签: url-rewriting

如何在ASP.NET web.config文件中配置Intelligencia.UrlRewriter,将所有http://www.domain.com流量重定向到http://domain.com

2 个答案:

答案 0 :(得分:2)

<if header="host" match="www.yoursite.com" />
    <redirect url="^(.+)$" to="http://yoursite.com$1" />
</if>

答案 1 :(得分:0)

谢谢,dana,但这是我最终添加到我的web.config文件......

<system.webServer>
  <rewrite>
    <rules>
      <rule name="Redirect to WWW" stopProcessing="true">
        <match url=".*" />
        <conditions>
          <add input="{HTTP_HOST}" pattern="^www.mysite.com$" />
        </conditions>
        <action type="Redirect" url="http://mysite.com/{R:0}" redirectType="Permanent" />
      </rule>
    </rules>
  </rewrite>
</system.webServer>