开发者

redirect example.com to www.example.com with IIS7

开发者 https://www.devze.com 2023-03-12 14:28 出处:网络
I\'ve g开发者_Go百科one through many suggestions here and on the web, and still am failing to make this work. I currently have the following, but it\'s not working. All help appreciated!

I've g开发者_Go百科one through many suggestions here and on the web, and still am failing to make this work. I currently have the following, but it's not working. All help appreciated!

<rules>
   <rule name="www-less redirect" stopProcessing="true">
   <match url="(.*)" />
     <conditions>
      <add input="{HTTP_HOST}" pattern="^example\.com$" />
                </conditions>
                <action type="Redirect" url="http://www.example.com/{R:1}" />
              </rule>
        </rules>


Your rule seems fie. Try this one (slightly different) -- works fine for me:

<rule name="CanonicalHostName">
    <match url="(.*)" />
    <conditions>
        <add input="{HTTP_HOST}" pattern="^www\.example\.com$" negate="true" />
    </conditions>
    <action type="Redirect" url="http://www.example.com/{R:1}" />
</rule>

1) Try moving this rule to the top (make it first rule).

2) Possibly (just possibly) you do not have binding for example.com, only for www.example.com ?

0

精彩评论

暂无评论...
验证码 换一张
取 消