我想重寫HTTP到我的IIS 8.5 Web服務器上特定子文件夾的HTTPS,但它不工作。我讀過無數其他解決方案和博客文章,但沒有我嘗試過的作品。只重寫子文件夾(HTTP到HTTPS)重定向到站點根目錄
http://domain.example.com/one/two/three/
應該重定向到...(相同的URL,但使用HTTPS)
https://domain.example.com/one/two/three/
而是被重定向到...(使用站點根HTTPS)
https://domain.example.com
加載。 ..(使用https所需的網址)
https://domain.example.com/one/two/three/
也會重定向到...(使用https的網站根目錄)
https://domain.example.com
它將從url中刪除子文件夾。
此文件夾還需要使用Windows身份驗證進行保護,我可以開始工作,但https重定向失敗,無論是否啓用身份驗證,所以我不認爲這是原因。
在IIS中,我選擇了所需的子文件夾(在上例中爲/ three /),並在那裏創建了重寫規則。
<rewrite>
<rules>
<clear />
<rule name="HTTP to HTTPS redirect" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" appendQueryString="true" redirectType="SeeOther" />
</rule>
</rules>
</rewrite>
這當然適用於所需子文件夾中包含的任何文件和文件夾。 (/三相)
我想這和它重定向到明顯的正確的URL,但給出了「過多的重定向」錯誤:
<rule name="HTTP to HTTPS redirect" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll">
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" appendQueryString="false" redirectType="SeeOther" />
</rule>