IIS web.config将www重定向到非www并将http重定向到https

问题描述 投票:0回答:1

使用此代码时,我的浏览器显示“ example.com当前无法处理此请求HTTP ERROR 500:

<rule name="Force WWW and SSL" enabled="true" stopprocessing="true">
<match url="(.*)"/>
<conditions logicalgrouping="MatchAny">
<add input="{HTTP_HOST}" pattern="^[^www]"/>
<add input="{HTTPS}" pattern="off"/>
</conditions>
<action type="Redirect" url="https://example.com/{R:1}" appendquerystring="true" redirecttype="Permanent"/>
</rule>

我正在尝试将http://example.comhttp://www.example.com都重定向到我的SSL https://example.com。为什么不起作用?

iis web-config
1个回答
0
投票

如果仅要将Http重定向到https,则只需添加{HTTPS}服务器变量以匹配Non-HTTP协议就足够了。

© www.soinside.com 2019 - 2024. All rights reserved.