注意首先要安装url重定向模块
https://www.microsoft.com/zh-CN/download/details.aspx?id=7435
然后在web.config末尾添加如下代码
<
system.webServer>
<rewrite>
<rules>
<rule name="
HTTP to HTTPS redirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" redirectType="Found" url="https://{HTTP_HOST}/{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>