通过修改web.config实现http自动301到https地址

直接上代码:

1
2
3
4
5
6
7
8
<rewrite
     <rule name="https" stopProcessing="true">
        <match url="(.*)" />    <conditions>
      <add input="{HTTPS}" pattern="off" />
    </conditions>
    <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" />
     </rule>
   </rewrite>

使用须知:此代码直接复制到iis站点根目录的web.config的<system.webserver>内即可

注意事项:服务器必须安装 rewrite 如果没有安装请在本站首页查找下载并按照

相关推荐

评论

展开