我正在尝试在 IIS 上的网站上启用 HTTPS。我想将用户从 http 重定向到 https。
我已将 web.config 中的规则相应更新为
<rewrite>
<rules>
<rule name="Redirect to HTTPs" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
我能够将请求转换为 https,但随后它会继续重定向到 https 的相同网址。问题是,该规则显然不断重定向所有 url,包括 https,然后网络选项卡中的浏览器保留大量 301 并最终抛出
This webpage has a redirect loop
ERR_TOO_MANY_REDIRECTS
如果有人解决过类似的情况,请帮助我。如果需要的话我可以提供更多信息。
谢谢
尝试以下重写规则。这适用于由单个 IIS 服务器提供服务的网站。负载平衡环境或服务器公司需要一些调整。
<rewrite>
<rules>
<rule name="Redirect to HTTPs" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="OFF" />
</conditions>
<action type="Redirect" redirectType="Permanent" url="https://{HTTP_HOST}/{R:1}" />
</rule>
</rules>
</rewrite>
您也可以看看问题和解决方案here
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)