[IIS] http 強制轉成https 方法


開啟網站應用程式根目錄下的 web.config 設定檔,並且找到 <system.webServer> 區段,加入以下設定即可完成:


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

IIS7 以上請安裝 URL Rewrite
https://www.iis.net/downloads/microsoft/url-rewrite

留言

這個網誌中的熱門文章

[Windows]密碼複雜性需求 停用密碼複雜度

net use 系統發生 1219 錯誤