[英]Redirect a site to SSL using IIS/rewrite module
我正在嘗試使用IIS /重寫模塊將網站的所有URL重定向到SSL。
我有一條規則,該規則適用於除包含虛擬目錄/應用程序(稱為“博客”)的網址以外的所有網址
<rule name="Force WWW and SSL" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTP_HOST}" pattern="^[^www]" />
<add input="{HTTPS}" pattern="off" />
</conditions>
<action type="Redirect" url="https://www.example.com/{R:1}" appendQueryString="true" redirectType="Permanent" />
</rule>
因此,將www.example.com/blog/post/test重定向到https無效,但是www.example.com/pages/demo可以。
出於某種原因,www.example.com / blog會重定向,而www.example.com/blog/不會。
如果有人能指出我正確的方向。 我討厭這個重寫/正則表達式的東西
如果要在所有URL上將特定站點強制從HTTP轉換為HTTPS並討厭Regex,則
這應該適用於HTTP到https
<rewrite>
<rules>
<rule name="HTTP to HTTPS" patternSyntax="Wildcard" stopProcessing="true">
<match url="*" />
<conditions>
<add input="{HTTPS}" pattern="off" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent" />
</rule>
</rules>
通常,當我玩urlrewrite / redirection時,我使用重定向類型“ temporary”,以便瀏覽器不緩存HTTP到HTTPS規則。 完成測試后,我將重定向類型更改為永久類型。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.