IIS http 重定向到https

在IIS中把http重定向到https有多种方式,常见如下:

1.在<system.webserver>节点下添加子节点:
<rewrite>
<rules>
<clear/>
<rule name="Redirect HTTP to HTTPS" stopProcessing="true">
<match url="(.*)"/>
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{HTTPS}" pattern="^OFF$"/>
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}{HTTP_URL}" redirectType="Found"/>
</rule>
</rules>
</rewrite>

2.IIS 配置URL Rewrite(配置后会生成上面的节点,同样效果)

添加规则
正则匹配模式->正则: (.*) -> condition-> {HTTPS} | ^OFF$
->Action ->Redirect->https://{HTTP_HOST}{HTTP_URL}->302

原文地址:https://www.cnblogs.com/DONET-LC/p/14134451.html