IIS7/IIS7.5 URL 重写 HTTP 重定向到 HTTPS的方法

 更新时间:2016年7月4日 17:52  点击:1843

1、有SSL证书,或者新购。目前很多免费的SSL证书

2、IIS7 / IIS 7.5 下绑定 HTTPS 网站

3、下载安装URL重写模块:Microsoft URL Rewrite Module

32位:http://download.microsoft.com/download/4/9/C/49CD28DB-4AA6-4A51-9437-AA001221F606/rewrite_x86_zh-CN.msi

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

4、取消勾选“SSL设置”-》“要求 SSL”

IIS7 / IIS7.5 URL 重写 HTTP 重定向到 HTTPS - 第1张 | Мало(mano) BLOG

5、ASP.NET站可直接修改web.config(与“6、IIS配置图示”效果相同),例如:见<rewrite>…</rewrite>节点

<?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>

6、IIS配置图示(图形化的操作过程,与上步效果相同,适用于asp/php等站)

选择要配置的网站,如:IIS7 / IIS7.5 URL 重写 HTTP 重定向到 HTTPS - 第4张 | Мало(mano) BLOG,找到“URL重写”,没有的话看上面第3步

IIS7 / IIS7.5 URL 重写 HTTP 重定向到 HTTPS - 第5张 | Мало(mano) BLOG

进入“URL重写”模块,点击“添加规则”

IIS7 / IIS7.5 URL 重写 HTTP 重定向到 HTTPS - 第6张 | Мало(mano) BLOG

选择“空白规则”

IIS7 / IIS7.5 URL 重写 HTTP 重定向到 HTTPS - 第7张 | Мало(mano) BLOG

名称:HTTP to HTTPS redirect

模式:(.*)

IIS7 / IIS7.5 URL 重写 HTTP 重定向到 HTTPS - 第8张 | Мало(mano) BLOG

IIS7 / IIS7.5 URL 重写 HTTP 重定向到 HTTPS - 第9张 | Мало(mano) BLOG

条件输入:{HTTPS}

模式:off 或 ^OFF$

IIS7 / IIS7.5 URL 重写 HTTP 重定向到 HTTPS - 第10张 | Мало(mano) BLOG 或 IIS7 / IIS7.5 URL 重写 HTTP 重定向到 HTTPS - 第11张 | Мало(mano) BLOG

重定向URL:https://{HTTP_HOST}/{R:1}

重定向类型:已找到(302) 或 参阅其它(303)

IIS7 / IIS7.5 URL 重写 HTTP 重定向到 HTTPS - 第12张 | Мало(mano) BLOGIIS7 / IIS7.5 URL 重写 HTTP 重定向到 HTTPS - 第13张 | Мало(mano) BLOG

配置完成后“应用”到当前站点:

IIS7 / IIS7.5 URL 重写 HTTP 重定向到 HTTPS - 第14张 | Мало(mano) BLOG

URL重写配置结果:

IIS7 / IIS7.5 URL 重写 HTTP 重定向到 HTTPS - 第15张 | Мало(mano) BLOG

至此配置完成!

[!--infotagslink--]

相关文章