1、购买SSL证书(我用的阿里云的免费证书),然后IIS设置好SSL。
2、如果IIS没有URL重写模块,则需要下载安装URL重写模块:Microsoft URL Rewrite Module
3、取消勾选“SSL设置”-》“要求 SSL”
4、URL重写规则:ASP.NET站可直接修改web.config,和界面操作结果一致,例如:
<div ?>="" <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" rule>="" rules>="" rewrite>="" system.webserver>="" configuration><="" div="" style="box-sizing: inherit; color: rgb(85, 85, 85); font-family: Lato, sans-serif; font-size: 15px; white-space: normal; background-color: rgb(255, 255, 255);">
5、URL重写规则:图形化配置 找到“URL重写”
添加规则
添加入站空白规则
规则详情
主要参数
名称:HTTP to HTTPS redirect
模式:(.*)
条件输入:{HTTPS}
模式:off 或 ^OFF$
重定向URL:https://{HTTP_HOST}/{R:1}
重定向类型:已找到(302) 或 参阅其它(303)
配置完成后“应用”到当前站点
URL重写配置结果
验证
通过http访问站点,若自动重定向至https则配置成功!
本文采摘于网络,不代表本站立场,转载联系作者并注明出处:https://www.5amiao.com/baike/1840.html