【问题标题】:HTTPS www redirects in web.configweb.config 中的 HTTPS www 重定向
【发布时间】:2017-12-21 16:52:16
【问题描述】:

我的 web.config 中有以下内容来强制 https;

<rule name="Redirect to https" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" appendQueryString="false" />
</rule>

但我想强制 www。同样,所有这些都将转到https://www 版本。我需要达到的目标:

http://www.domain.tld/whatever
http://(no-www)domain.tld/whatever
https://(no-www)domain.tld/whatever

谢谢。

【问题讨论】:

  • @cfnerd 嗨,我首先使用了它,但它不包括如何强制 www。部分。

标签: redirect iis web


【解决方案1】:

此规则将执行以下操作:

  • 重定向到 HTTPS
  • 强制 www

<rule name="Redirect to https" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTPS}" pattern="off" />
<add input="{HTTP_HOST}" pattern="^www." negate="true" />
</conditions>
<action type="Redirect" url="https://www.example.com{REQUEST_URI}" redirectType="Permanent" appendQueryString="false" />
</rule>

您只需将www.example.com 更改为您的域名

【讨论】:

    猜你喜欢
    • 2018-03-31
    • 1970-01-01
    • 1970-01-01
    • 2017-03-30
    • 1970-01-01
    • 1970-01-01
    • 2017-12-01
    • 1970-01-01
    • 2022-03-04
    相关资源
    最近更新 更多