【问题标题】:IIS HTTPS infinite redirectIIS HTTPS 无限重定向
【发布时间】:2017-11-01 11:14:30
【问题描述】:

我的 webconfig 中的 HTTPS 重定向配置有问题:

<rewrite>
    <rules>
        <rule name="Redirect to HTTPS" stopProcessing="true">
          <match url="(.*)" />
          <conditions>
            <add input="{HTTP_HOST}" pattern="^domain\.be$" negate="true" />
            <add input="{HTTPS}" pattern="OFF" ignoreCase="true" />
          </conditions>
          <action type="Redirect" url="http://www.domain.be/{R:1}" />
        </rule>
        <rule name="Redirect to WWW" stopProcessing="true">
          <match url=".*" />
          <conditions logicalGrouping="MatchAny">
            <add input="{HTTP_HOST}" pattern="^domain\.be$" />
          </conditions>
          <action type="Redirect" url="https://www.domain.be/{R:0}" redirectType="Permanent" />
        </rule>
  </rules>
</rewrite>

以下代码适用于:

但不适用于:

  • www.domain.be

当我访问该 URL 时,总是会收到无限重定向错误。

谁能指出我在 web.config 中的错误?

提前致谢

【问题讨论】:

标签: .net redirect iis https


【解决方案1】:

此规则可用于将非 HTTPS 和非 www.domain.be 的所有内容发送到 https://www.domain.be/

<rewrite>
    <rules>
        <rule name="redirect to https www" stopProcessing="true">
          <match url="(.*)" />
          <conditions logicalGrouping="MatchAny">
            <add input="{HTTP_HOST}" pattern="^www\.domain\.be$" negate="true" />
            <add input="{HTTPS}" pattern="ON" ignoreCase="true" negate="true" />
          </conditions>
          <action type="Redirect" url="https://www.domain.be/{R:0}" />
        </rule>
    </rules>
</rewrite>

【讨论】:

    猜你喜欢
    • 2018-03-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-02
    • 1970-01-01
    • 2018-01-18
    • 2016-12-24
    相关资源
    最近更新 更多