IIS - HTTPS和WWW重定向

问题描述 投票:0回答:1

所以我正在使用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

url iis url-rewriting
1个回答
0
投票

此规则将所有内容重定向到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文件中添加此规则

© www.soinside.com 2019 - 2024. All rights reserved.