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