IIS7 IIS8 IIS10自动跳转到HTTPS

发布时间:2016/10/24 23:44:29 打印 字号:

IIS7需要先确认是否安装 “URL 重写” 或者 “URL Rewrite” 模块 , 如果您已经安装可以跳过

“URL重写” 模块下载地址

微软下载地址:https://www.iis.net/downloads/microsoft/url-rewrite

简体中文:x86安装程序/ x64安装程序

英语:Web平台安装程序(WebPI) / x86安装程序/ x64安装程序

第一步: 选择站点,  “URL 重写”,如果安装的是英文版的 应该是【Url Rewrite】

第二步: 添加 “ 空白规则”

2016102485527073.jpg (690×456)

第三步:添加规则

名称 : HTTPS
匹配URL 模式: (.*)
添加条件:    条件: {HTTPS}  模式: off

操作类型选择:重定向
重定向URL: https://{HTTP_HOST}/{R:1}

2016102485534009.jpg (587×510)

2016102485540897.jpg (584×324)


然后保存即可

 

高级版(直接把伪静态添加到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 logicalGrouping="MatchAny">
<add input="{HTTPS}" pattern="off" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>