繁体   English   中英

IIS 使用 https 将 www 重定向到非 www

[英]IIS redirect www to non www using https

我需要一些帮助来实现重定向。

我得到的结果如下:

http://example.com - https://example.com   : works
http://www.example.com - https://example.com   : works
https://www.example.com - https://example.com   : doesn't work

我的配置文件:

<rule name="RedirectWwwToNonWww" stopProcessing="false">
                    <match url="(.*)" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                        <add input="{HTTP_HOST}" pattern="^(www\.)(.*)$" />
                    </conditions>
                    <action type="Redirect" url="https://{C:2}{REQUEST_URI}" redirectType="Permanent" />
                </rule>
                <rule name="HTTP Redirect to HTTPS" enabled="true" stopProcessing="true">
                    <match url="(.*)" ignoreCase="false" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                        <add input="{HTTPS}" pattern="off" />
                    </conditions>
                    <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" appendQueryString="true" redirectType="Permanent" />
                </rule>

你可以试试这个规则:

<rule name="Force non-WWW" enabled="true" stopProcessing="true">
  <match url="(.*)" />
    <conditions logicalGrouping="MatchAny">
      <add input="{HTTP_HOST}" pattern="^(www\.)(.*)$" />
    </conditions>
  <action type="Redirect" url="https://{C:2}/{R:1}" appendQueryString="true" />
</rule>
<rule name="Force HTTPS" enabled="true" stopProcessing="true">
  <match url="(.*)" />
    <conditions logicalGrouping="MatchAny">
      <add input="{HTTPS}" pattern="off" />
    </conditions>
  <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" appendQueryString="true" />
</rule>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM