繁体   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