簡體   English   中英

使用web.config重寫規則將流量重定向到www和https

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM