iT邦幫忙

0

如何讓SSL安裝完後,HTTP轉HTTPS或者HTTPS降回HTTP

這邊是以Window Server為架構

前置作業
1.你要有申請SSL憑證,並安裝到Server
2.你的IIS的擴充模組安裝URL Rewrite

當以上前置作業都完成,就可以到web.config檔裡面,設定轉址規則囉~

以下就你想將HTTP協定轉成HTTPS的做法

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

當然如果你覺得不想再付憑證費了,也是可以降回HTTP協定,但是在到期之前,就要先下轉回的規則唷
否則你在搜尋引擎的網站列出,連結的網址在還沒有變回HTTP協定以前,點過去都會出現憑證錯誤的警告唷

<rewrite>
  <rules>
    <rule name="HTTPS to HTTP redirect" stopProcessing="true">
      <match url="(.*)" />
      <conditions>
        <add input="%{HTTPS}" pattern="on" ignoreCase="true" />
      </conditions>
      <action type="Redirect" redirectType="Found" url="http://{HTTP_HOST}/{R:1}" />
    </rule>
  </rules>
</rewrite>

紀錄...


圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言