質問

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