【问题标题】:Web config redrict when URL has HTTPSURL 具有 HTTPS 时的 Web 配置重定向
【发布时间】:2019-11-15 18:17:21
【问题描述】:

我想尝试从

重定向网站
"https://abcd.net-------------> https://www.abcd.net"

我已经重定向了

"http://abcd.net-------------> http://www.abcd.net"
"http://www.abcd.net-------------> https://www.abcd.net"




<rule name="Force HTTPS" enabled="true" stopProcessing="true">
    <match url="(.*)" />
        <conditions logicalGrouping="MatchAll">
            <add input="{HTTPS}" negate="true" pattern="^ON$" />
                </conditions>
    <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" appendQueryString="false" redirectType="Permanent" />
</rule>

需要重定向所有 abcd.net 通过 www 访问 HTTPS

【问题讨论】:

    标签: .net redirect iis url-rewriting web-config


    【解决方案1】:

    根据你的描述,我建议你可以尝试添加一个新的url重写规则来匹配“https://abcd.net”重定向到“https://www.abcd.net”。

    详情,可参考以下重写规则:

      <rule name="Redirect https" enabled="true" stopProcessing="true">
        <match url="(.*)" />
        <conditions logicalGrouping="MatchAll">
          <add input="{HTTPS}"   pattern="^ON$" />
          <add input="{HTTP_HOST}" pattern="abcd.net" />
        </conditions>
        <action type="Redirect" url="https://www.abcd.net/{R:0}" appendQueryString="false" redirectType="Permanent" />
      </rule>
      <rule name="Force HTTPS" enabled="true" stopProcessing="true">
        <match url="(.*)" />
        <conditions logicalGrouping="MatchAll">
          <add input="{HTTPS}" negate="true" pattern="^ON$" />
        </conditions>
        <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" appendQueryString="false" redirectType="Permanent" />
      </rule>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-10-11
      • 1970-01-01
      • 2015-02-27
      • 2017-11-29
      • 2020-09-28
      • 1970-01-01
      • 2020-05-28
      • 2020-09-25
      相关资源
      最近更新 更多