开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜