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

作者: 时间:
浏览 : 763

配置好了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标签:

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注