IIS设置网站为HTTPS并且将HTTP重定向到HTTPS

第一步:下载证书,导入证书到IIS
https://help.aliyun.com/knowledge_detail/95502.html

站点绑定https

 

第二部:安装URL重写模块
rewrite_amd64_zh-CN.msi

 

安装完成重启IIS

 

第三步:选中你的站点后,双击进入URL重写右键添加规则

其实这一步就是在站点的Web.config增加了一段配置:

<system.webServer>
<rewrite>
<rules>
<rule name="http转https" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
如果下一个站点也需要设置HTTP重定向HTTPS,直接在Web.config增加这段配置就行。

posted @ 2021-12-04 23:09  zhihua  阅读(394)  评论(0)    收藏  举报