【问题标题】:IIS7 https to http redirect not working on www subdomainIIS7 https 到 http 重定向不适用于 www 子域
【发布时间】:2014-07-31 04:30:34
【问题描述】:

我试图在我们网站的所有页面上强制使用 http,但结帐页面除外。我使用了下面的重写规则,但它不适用于 url 中的 www 子域。

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

<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 重写经验的人能给我一些帮助。

【问题讨论】:

    标签: iis redirect rewrite


    【解决方案1】:

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

        <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>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-07-27
      • 1970-01-01
      • 1970-01-01
      • 2018-06-02
      • 2018-05-24
      • 1970-01-01
      • 2015-05-19
      • 2018-06-01
      相关资源
      最近更新 更多