欢迎光临众联科技,开始互联网之旅! 请〖登录〗 〖注册〗
IIS http强制重定向到https
发布时间:2017/9/29 1:01:22   发布来源:众联科技

首先安装 URL Rewrite 模块 ,下载网址 

http://www.iis.net/downloads/microsoft/url-rewrite

安装完成后, 在网站根目录下建立web.config 文件,文件内容如下 

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <rewrite>
      <rules>
        <rule name="HTTP/S to HTTPS Redirect" enabled="true" stopProcessing="true">
        <match url="(.*)" />
        <conditions logicalGrouping="MatchAny">
          <add input="{SERVER_PORT_SECURE}" pattern="^0$" />
        </conditions>
        <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>


即可实现每次用户只要在浏览器打开www.abc.com 即自动跳转到https://www.abc.com


(责任编辑:众联科技)
微信公众号
微信公众号 关注有礼
  • 服务支持
  •