我最近爲我的網站獲得了SSL證書,並且希望將所有流量重定向到HTTPS。我得到了一切去https://mydomain.com
,但如果有人輸入http://mydomain.com/anotherpage
它放棄其他頁面,並只需要用戶到主頁。IIS HTTP到HTTPS相對重定向
我在我的web.config
文件規則是這樣的:
<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>
我也試過https://{HTTP_HOST}{REQUEST_URI}
沒有任何成功。任何人都可以告訴我,我需要做些什麼來使網站重定向到正確的HTTPS版本的頁面?我有一種感覺,它與模式有關,但我似乎無法弄清楚語法。
我認爲它與後面的參考有關。如果將模式更改爲'url =「。*」',並重寫爲'url =「https:// {HTTP_HOST}/{R:0}」',會怎麼樣? – cheesemacfly
仍然會將所有內容重新導向至主頁。 – user2234612
這真的很奇怪。你將不得不使用[失敗的請求追蹤](http://www.iis.net/learn/extensions/url-rewrite-module/using-failed-request-tracing-to-trace-rewrite-rules)工具來看問題來自哪裏。 – cheesemacfly