IIS (安裝SSL證書後) 實現 HTTP 自動跳轉到 HTTPS ...
IIS 里 安裝好 SSL 證書後,如何實現 在瀏覽器里錄入 http://www.xxx.com,會自動跳轉到 https://www.xxx.com 呢。
首先,下載並安裝 IIS 擴展: URL重寫(URL Rewrite)擴展
URL重寫擴展下載地址: https://www.iis.net/downloads/microsoft/url-rewrite
其次,修改 web.config 文件:
<?xml version="1.0" encoding="UTF-8"?> <configuration> <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> </configuration>
最後,重啟網站 或重啟 IIS。在瀏覽器里錄入:http://www.xxx.com,會自動跳轉到 https://www.xxx.com