[英]redirect https:// to https://www in IIS 8
假設我有一個網站http://www.example.com ,它是從http://example.com重定向到http://www.example.com的 301。
現在,在Google最近發布有關使用SSL獲得更好排名的更新之后,我決定使用SSL。
我在web.config
使用以下代碼將301重定向到https
<rewrite>
<rules>
<rule name="Redirect to HTTPS" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://www.example.com/{R:1}" />
</rule>
</rules>
</rewrite>
現在,它會將所有請求http://www.example.com和http://example.com重定向301到https://www.example.com
但不會將https://example.com重定向到https://www.example.com
我想僅針對許多SEO權威網站建議的規范版本執行此操作。
如果我使用Plesk內置功能將所有非www重定向到www,則它會進行兩次重定向。
我該怎么辦,請幫忙
嘗試使用第二條規則來實施www,例如:
<rule name="Enforce WWW" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{CACHE_URL}" pattern="^https://(?!www)(.*)" />
</conditions>
<action type="Redirect" url="https://www.{C:1}" redirectType="Permanent" />
</rule>
您的規則所具有的條件將阻止它針對諸如https://example.com之類的https請求觸發。
版本#2嘗試將此規則放在其他規則之前,stopProcessing應該阻止它循環運行。
<rule name="Enforce WWW" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="example.com" />
</conditions>
<action type="Redirect" url="https://www.example.com/{R:0}" />
</rule>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.