IIS 强制跳转https

发布时间 2023-10-29 00:07:07作者: evemen

1、点击以下下载链接安装64位的URL重写模块:Microsoft URL Rewrite Module。

http://download.microsoft.com/download/C/9/E/C9E8180D-4E51-40A6-A9BF-776990D8BCA9/rewrite_amd64.msi

2、IIS控制台,取消勾选“SSL设置”->“要求 SSL”,右侧工具栏选择“应用”保存。

IIS http重定向https,强制用户使用https访问的配置方法

 

3、ASP.NET站可直接修改web.config。IIS控制台右键单击需要设置的站点,选择“浏览”,编辑Web.config文件。在system.webServer之间添加以下内容:

web.config
<configuration>
<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>
</configuration>

转自https://www.cnblogs.com/guohu/p/14492491.html