IIS 配置Http重定向到Https

时间:2022-01-30 03:35:15
注意首先要安装url重定向模块
然后在web.config末尾添加如下代码
 <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>