【问题标题】:Force to use HTTPS redirects page to http://http/ url强制使用 HTTPS 将页面重定向到 http://http/ url
【发布时间】:2018-03-14 18:59:10
【问题描述】:

我已将此代码添加到web.config 文件的Configuration -> system.webServer 部分,以强制用户使用https:

<rewrite>
<rules>
    <rule name="HTTP to HTTPS redirect" stopProcessing="true">
        <match url="(.*)" />
        <conditions>
            <add input="{HTTPS}" pattern="off" ignoreCase="true" />
        </conditions>
        <action type="Redirect" url="https://{HTTP_HOST}/{R:1}"
            redirectType="Permanent" />
    </rule>
</rules>
<outboundRules>
    <rule name="Add Strict-Transport-Security when HTTPS" enabled="true">
        <match serverVariable="RESPONSE_Strict_Transport_Security"
            pattern=".*" />
        <conditions>
            <add input="{HTTPS}" pattern="on" ignoreCase="true" />
        </conditions>
        <action type="Rewrite" value="max-age=31536000" />
    </rule>
</outboundRules>
</rewrite>

但是当我访问我的网站时,它会将页面重定向到以下网址: http://http/

注意事项:

  • 我正在使用 Orchard CMS 版本 1.10.x
  • 当我使用 Orchard 的 SSL 插件强制所有页面使用 SSL 时,再次发生这种情况。
  • 在 Orchard 的设置中启用了 SSL 重定向。
  • 在我的 Plesk 控制面板中正确设置了 SSL/TLS 证书。
  • 网站目前使用“Let's Encrypt”进行保护。当我使用 Cloudflare 服务时也会出现此问题。
  • 我测试过的每个网络浏览器都会出现这种情况。

【问题讨论】:

    标签: ssl redirect iis web-config orchardcms


    【解决方案1】:

    我使用相同的重写规则将我的页面重定向到 https,使用 Plesk 面板上的 Orchard 和 Let's Encrypt 证书。此规则将每个 http 调用重定向到 https。 您必须禁用 Orchard 安全套接字层插件,因为您在 web.config 中制定了自己的规则。 如果您想使用 Orchard 插件,请删除您的重写规则并改用该插件。

    【讨论】:

    • 我都试过了。首先,我禁用了 SSL 插件并在 sn-p 之上使用。然后启用 SSL 插件并删除了 sn-p,但在这两种情况下仍然是同样的问题。
    猜你喜欢
    • 2020-05-28
    • 2016-11-14
    • 2019-12-14
    • 2020-07-23
    • 1970-01-01
    • 1970-01-01
    • 2015-11-02
    • 1970-01-01
    • 2013-10-18
    相关资源
    最近更新 更多