张文保的博客
张文保 · Paul Zhang

Engineering the Future
功不唐捐,玉汝于成

IIS7设置http跳转到https重定向的方法

配置好了https站点后,还需要设置301跳转,http站点跳转到https站点。先下载安装URL重写模块:Microsoft URL Rewrite Module

32位URL重写模块下载:http://download.microsoft.com/download/4/9/C/49CD28DB-4AA6-4A51-9437-AA001221F606/rewrite_x86_zh-CN.msi

64位URL重写模块:http://download.microsoft.com/download/4/E/7/4E7ECE9A-DF55-4F90-A354-B497072BDE0A/rewrite_x64_zh-CN.msi

下载对应的文件在服务器上安装好后,新建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$" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>

将web.config放在网站根目录后,重启IIS即可

TAG标签
IIS

相关文章
本文标题:《IIS7设置http跳转到https重定向的方法》
网址:https://zhangwenbao.com/iis7-set-http-to-https-redirect.html
作者:张文保
发布时间:2017-03-01
许可协议:CC BY-NC-SA 4.0
发表新评论
SSL安全认证