![](/img/trans.png)
[英]IIS Rewrite Rule Redirect HTTP to HTTPS causes multiple RedirectURL querystring
[英]IIS rewrite rule to redirect https to http not working
這里有很多關於將http重定向到https的問題,所以我認為很容易逆轉這個過程。 但是,我嘗試過的一切都沒有奏效。
我正在嘗試將規則與我的規范主機名規則相結合(這是第一條規則,在重寫規則的頂部):
<rule name="CanonicalHostName" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTPS}" pattern="^ON$" />
<add input="{HTTP_HOST}" negate="true" pattern="^www\.example\.com|example-staging\.azurewebsites\.net$" />
</conditions>
<action type="Redirect" url="http://www.example.com/{R:1}" redirectType="Permanent" />
</rule>
該網站托管在Azure上,DNS與CloudFlare一起使用,如果這有任何區別,我相信它不應該。
任何想法我做錯了/可能會阻止https到http規則的一部分工作? (主機名部分工作正常)
您似乎無法從SSL重定向的原因是因為您使用的是CloudFlare。 CloudFlare至少使用靈活的SSL。 這意味着最終用戶,瀏覽器顯示SSL鎖定,但您的服務器不需要SSL。 請參閱此處的文檔: https : //www.cloudflare.com/ssl
如果沒有CloudFlare,以下示例應該可以正常工作。
以下規則應該有效。 如果你願意,你仍然可以添加你的否定。
<rule name="HTTPS to HTTP redirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="on" ignoreCase="true" />
</conditions>
<action type="Redirect" redirectType="Found" url="http://{HTTP_HOST}/{R:1}" />
</rule>
我的工作演示站點的完全重寫部分。
<rewrite>
<rules>
<rule name="CanonicalHostNameRule1">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^www\.ashleymedway\.com$" negate="true" />
</conditions>
<action type="Redirect" url="http://www.ashleymedway.com/{R:1}" />
</rule>
<rule name="HTTPS to HTTP redirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="on" />
</conditions>
<action type="Redirect" url="http://{HTTP_HOST}/{R:1}" redirectType="Found" />
</rule>
</rules>
</rewrite>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.