IIS中設(shè)置HTTP訪問(wèn)重定向到HTTPS
目錄
- 添加規(guī)則
- 添加入站空白規(guī)則
- 規(guī)則詳情
- 配置完成后“應(yīng)用”到當(dāng)前站點(diǎn)
- URL重寫(xiě)配置結(jié)果
- 驗(yàn)證
- 參考文章:
不啰嗦,我們直接開(kāi)始!
1、購(gòu)買(mǎi)SSL證書(shū)(我用的阿里云的免費(fèi)證書(shū)),然后IIS設(shè)置好SSL。
2、如果IIS沒(méi)有URL重寫(xiě)模塊,則需要下載安裝URL重寫(xiě)模塊:Microsoft URL Rewrite Module
3、取消勾選“SSL設(shè)置”-》“要求 SSL”
4、URL重寫(xiě)規(guī)則:ASP.NET站可直接修改web.config,和界面操作結(jié)果一致,例如:
<?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>
5、URL重寫(xiě)規(guī)則:圖形化配置 找到“URL重寫(xiě)”
添加規(guī)則
添加入站空白規(guī)則
規(guī)則詳情
主要參數(shù)
名稱:HTTP to HTTPS redirect
模式:(.*)
條件輸入:{HTTPS}
模式:off 或 ^OFF$
重定向URL:https://{HTTP_HOST}/{R:1}
重定向類型:已找到(302) 或 參閱其它(303)
配置完成后“應(yīng)用”到當(dāng)前站點(diǎn)
URL重寫(xiě)配置結(jié)果
驗(yàn)證
通過(guò)http訪問(wèn)站點(diǎn),若自動(dòng)重定向至https則配置成功!
參考文章:
到此這篇關(guān)于IIS中設(shè)置HTTP訪問(wèn)重定向到HTTPS的文章就介紹到這了,更多相關(guān)IIS HTTP重定向到HTTPS內(nèi)容請(qǐng)搜索以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持!
