IIS - HTTPS和WWW重定向

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了IIS - HTTPS和WWW重定向相关的知识,希望对你有一定的参考价值。

所以我正在使用iis 8并尝试将我网站的所有版本重定向到1。

比如说:

http://www.osrshub.com
www.osrshub.com
osrshub.com
http://osrshub.com
https://osrshub.com
https://www.osrshub.com

当用户点击任何这些链接时,我需要它重定向到1个主链接。

https://www.osrshub.com

我正在使用Windows Server 2012

答案

此规则将所有内容重定向到https://www.osrshub.com

<rule name="All in one rule" stopProcessing="true">
   <match url=".*" />
   <conditions logicalGrouping="MatchAny">
      <add input="{HTTPS}" pattern="off" />
      <add input="{HTTP_HOST}" pattern="^www.osrshub.com$" negate="true" />
    </conditions>
    <action type="Redirect" url="https://www.osrshub.com/{R:0}" />
</rule>

您需要在web.config文件中添加此规则

以上是关于IIS - HTTPS和WWW重定向的主要内容,如果未能解决你的问题,请参考以下文章

如何将所有非 www 的 URL 重定向到 https://www。在 IIS 中?

iis url 将 http 重定向到非 www https

IIS 配置Http重定向到Https

IIs 8 将 URL 从 http 重定向到 https

IIS HTTP重定向到HTTPS

web.config 中的 IIS 重写规则将 HTTPS 请求重定向到 HTTP