【发布时间】:2020-03-26 06:28:41
【问题描述】:
我尝试了几乎所有与 http 到 https 重定向的 web.config 更改相关的赞成建议。 Best way in asp.net to force https for an entire site?
但它不适用于我的 ASP.net 网站。我使用 GoDaddy 共享主机,并且我的帐户中有多个站点。我只为一个网站启用了 ssl,并且必须将其添加到过滤器中,以便同一帐户中的其他网站不会重定向到 https。这是我的 web.config:
<rewrite>
<rules>
<rule name="HTTP to HTTPS redirect" stopProcessing="true" enabled="true">
<match url="singledomain.*" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" redirectType="Permanent" url="https://{HTTP_HOST}/{R:1}" />
</rule>
</rules>
</rewrite>
我目前可以通过 http 和 https 访问该站点。但它永远不会从 http 重定向到 https。匹配条件是否正确,如果正确,还有什么问题?
【问题讨论】:
-
如果我使用
那么它可以工作,但我的共享主机中的其他域也开始通过 https 提供服务,并且这些域没有 ssl,所以这些域可以没有加载。
标签: asp.net web-config