문제

I'm trying to do a simple redirect from the www subdomain to the root domain. After trying many variations, I'm stuck and hoping for help. Feeling sure it's something stupid, but can't see it. Here's the rule I'm using.

<rewrite>
  <rules>
    <rule name="Redirect to root" stopProcessing="true">
      <match url=".*"  />
      <conditions>
        <add input="{HTTP_HOST}" pattern="^www.stitchamerica.com$" negate="true" />
      </conditions>
      <action type="Redirect" url="http://stitchamerica.com/{R:1}" redirectType="Permanent" />
    </rule>
  </rules>
</rewrite>

Input greatly appreciated.

도움이 되었습니까?

해결책

This works for me:

    <rewrite>
      <rules>
        <rule name="Remove WWW" stopProcessing="true">
          <match url="^(.*)$" />
          <conditions>
            <add input="{HTTP_HOST}" pattern="^(www\.)(.*)$" />
          </conditions>
          <action type="Redirect" url="http://YOURSITE.com/{R:0}" redirectType="Permanent" />
        </rule>
      </rules>
    </rewrite>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top