确认是否安装 “URL 重写” 或者 “URL Rewrite” 模块 , 如果您已经安装可以跳过
“URL重写” 模块下载地址
微软下载地址(64位):http://www.microsoft.com/zh-cn/download/details.aspx?id=7435
微软下载地址(32位):http://www.microsoft.com/zh-cn/download/details.aspx?id=5747
名称 : HTTP响应
匹配范围:服务器变量
变量名称:RESPONSE_Strict_Transport_Security
模式:.*
条件输入:HTTPS
模式:on
值:max-age=31536000
高级配置,网站根目录创建:web.config文件夹,具体代码:
<?xml version="1.0" encoding="UTF-8"?> <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" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent" /> </rule> </rules> <outboundRules> <rule name="Add Strict-Transport-Security when HTTPS" enabled="true"> <match serverVariable="RESPONSE_Strict_Transport_Security" pattern=".*" /> <conditions> <add input="{HTTPS}" pattern="on" ignoreCase="true" /> </conditions> <action type="Rewrite" value="max-age=31536000; includeSubDomains; preload" /> </rule> </outboundRules> </rewrite> </system.webServer> </configuration>