需要先确认是否安装 “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
1. 选择站点, “URL 重写”,如果安装的是英文版的 应该是【Url Rewrite】

2.添加 “ 空白规则”

3.添加规则 名称 : HTTPS 匹配URL 模式: (.*) 添加条件: 条件: {HTTPS} 模式: off
操作类型选择:重定向 重定向URL: https://{HTTP_HOST}/{R:1}
 设置301跳转
 之后点击保存
当然也可以自己直接编辑网站配置文件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" redirectType="Found" url="https://{HTTP_HOST}/{R:1}" /> </rule> </rules> </rewrite> </system.webServer> </configuration>
|
|