代码之家  ›  专栏  ›  技术社区  ›  4b0 Agit

在IIS中重写URL并出现错误“页面重定向不正确”

  •  0
  • 4b0 Agit  · 技术社区  · 6 年前

    我试着重写 url 像下面一样。

    mail.test.com 必须重定向到 https . 以外 test 很好 http .

    <match url="(.*)" />
        <conditions>
          <add input="{HTTP_HOST}" pattern="^mail\.test\.com$" />
        </conditions>
    <action type="Redirect"  url="https://mail.test.com/{R:1}" />
    

    但我有一个错误:

    页面重定向不正确

    连接到mail.test.com时出错。

    此问题有时可能是由于禁用或拒绝接受cookie造成的。

    SSL证书和其他证书都可以。如果我不写这条规则,它会起作用的 HTTPS ,但其他人也重定向到 HTTPS . 我这里缺少什么?

    2 回复  |  直到 6 年前
        1
  •  1
  •   Peter Mortensen code4jhon    6 年前

    <rule name="HTTP to HTTPS" stopProcessing="true">
       <match url="(.*)" />
       <conditions logicalGrouping="MatchAll">
          <add input="{HTTP_HOST}" pattern="^(mail\.test\.com)$" />
          <add input="{HTTPS}" pattern="off" />
       </conditions>
       <action type="Redirect" url="https://mail.test.com/{R:1}" />
    </rule>
    

        2
  •  0
  •   4b0 Agit    6 年前

    <rewrite>
       <rules>
          <clear />
          <rule name="Redirect to https" stopProcessing="true">
             <match url=".*" />
             <conditions>
                <add input="{HTTPS}" pattern="mail\.test\.com$" />
             </conditions>
             <action type="Redirect" url="https://mail.test.com/{R:1}" />
          </rule>
       </rules>
    </rewrite>