[英]Redirect traffic to www and https using web.config rewrite rule
這是我設法挖掘的一些代碼:
<rule name="Redirect domain.com to www" patternSyntax="ECMAScript" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^inboxlock.com$" />
</conditions>
<action type="Redirect" url="https://www.inboxlock.com/{R:0}" />
</rule>
但是,如果有人輸入www.inboxlock.com,它不會重定向到https。 我需要www.inboxlock.com和domain.com都重定向到https://www.inboxlock.com 。 請幫忙。 謝謝。
<rule name="Enforce WWW" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{CACHE_URL}" pattern="^(.+)://(?!www)(.*)" />
</conditions>
<action type="Redirect" url="{C:1}://www.{C:2}" redirectType="Permanent" />
</rule>
我不能相信它。 在Mads Kristensen的有關URL重寫的博客文章中查看此代碼及更多內容。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.