3
重複的網址我需要強制每個請求https://www.mysite.com(總是以https和www)強制HTTPS並避免使用IIS7 URL重寫模塊
該網站在GoDaddy的託管,我需要通過IIS7 URL重寫模塊做。
我已經能夠做到HTTPS重定向用下面的代碼:
<system.webServer>
<rewrite>
<rules>
<rule name="Canonical Host Name" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^mysite\.com$" />
</conditions>
<action type="Redirect" url="https://www.mysite.com/{R:1}" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
</system.webServer>
測試用例
我猜t當我在瀏覽器中輸入www.mysite.com時,他的條件並未得到滿足,因此沒有重定向,並且該頁面用作HTTP而不是HTTPS。
我想我只需要修改條件模式,但我幾乎沒有任何正則表達式的知識,我需要這個儘快。
謝謝!