码迷,mamicode.com
首页 > Web开发 > 详细

IIS (安装SSL证书后) 实现 HTTP 自动跳转到 HTTPS

时间:2019-01-10 13:58:51      阅读:224      评论:0      收藏:0      [点我收藏+]

标签:stop   rewrite   nbsp   ons   nload   proc   https   ESS   自动跳转   

IIS 里 安装好 SSL 证书后,如何实现 在浏览器里录入 http://www.xxx.com,会自动跳转到 https://www.xxx.com 呢。

首先,下载并安装 IIS 扩展: URL重写(URL Rewrite)扩展

URL重写扩展下载地址: https://www.iis.net/downloads/microsoft/url-rewrite

 

其次,修改 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>

 

最后,重启网站 或重启 IIS。在浏览器里录入:http://www.xxx.com,会自动跳转到 https://www.xxx.com

 

IIS (安装SSL证书后) 实现 HTTP 自动跳转到 HTTPS

标签:stop   rewrite   nbsp   ons   nload   proc   https   ESS   自动跳转   

原文地址:https://www.cnblogs.com/anjou/p/10249466.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!