IIS7 https到http重定向不在www子域上工作

时间:2014-06-10 12:02:26

标签: iis redirect rewrite

我试图强制在我们网站的所有页面上使用http,但结帐页面除外。我已经使用了下面的重写规则,但它不能与网址中的www子域一起使用。

如果我使用https://domain.com,它会成功重定向到http://www.domain.com,但如果我尝试https与www没有任何反应。请注意,还有一个规范的域名重定向,但是如果没有此规则,这个问题仍然会发生。

<rule name="No-https" enabled="true" stopProcessing="true">
  <match url=".*" negate="false" />
  <action type="Redirect" url="http://{HTTP_HOST}{REQUEST_URI}" />
  <conditions>
    <add input="{HTTPS}" pattern="on" />
    <add input="{URL}" pattern="CheckOut" negate="true" />
  </conditions>
</rule>

这一直让我疯狂,我希望有更多IIS重写经验的人能给我一些帮助。

1 个答案:

答案 0 :(得分:0)

在类似的问题上花了几个小时。在我的情况下,我将流量从http重定向到https,我想在子域正在使用的情况下做同样的事情,例如http://subdomain.mydomain.com重写为https://subdomain.mydomain.com。似乎对于IIS 7.5,至少你需要在IIS中为每个特定的子域添加一个http绑定,否则它将不会被下面的catch匹配。

    <rewrite>
        <rules>
            <clear />
            <rule name="Redirect to https" stopProcessing="true">
                <match url="(.*)" />
                <conditions>
                    <add input="{HTTPS}" pattern="off" ignoreCase="true" />
                </conditions>
                <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" appendQueryString="false" />
            </rule>
        </rules>
    </rewrite>
相关问题