【问题标题】:IIS URL Rewrite for sub domains子域的 IIS URL 重写
【发布时间】:2022-01-21 16:45:29
【问题描述】:

我正在尝试在 IIS 中设置 URL 重写,它将接受来自根 https://www.test.com 的请求重定向到 https://www.test.com/nfc/,但当子域为“app”时不重定向请求(例如 @ 987654323@)。

我已经为 IIS 重写脚本配置了以下属性:

请求 URL:匹配模式 使用:正则表达式 图案:^$ 条件:{HTTP_HOST} 不匹配模式 ^app.test.com$ 操作类型:重定向 重定向网址:/nfc/ 重定向类型:307

是否有可能导致请求崩溃的递归重定向。 Here are the IIS settings

【问题讨论】:

    标签: iis url-rewrite-module


    【解决方案1】:

    你的规则有问题,你可以试试这个规则:

    <system.webServer>
      <rewrite>
        <rules>
            <rule name="test" stopProcessing="true">
                <match url="^$" />
                   <conditions>
                     <add input="{HTTP_HOST}" pattern="^app.test.com$" negate="true"/>
                   </conditions>
                <action type="Redirect" url="/nfc" />
            </rule>
        </rules>
      </rewrite>
    </system.webServer>
    

    【讨论】:

    • 但是如果子域是“app”(我不希望它在 app.test.com 的情况下重定向)。
    • 我编辑了我的答案,您可以尝试使用negate attribute 使其与子域不匹配。
    • 谢谢(我最终也是这样做的)。这条规则有可能造成无限循环吗?
    • “无限循环”是什么意思?能举个例子吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-05-11
    • 2017-08-24
    • 2011-12-07
    • 1970-01-01
    • 2014-11-14
    相关资源
    最近更新 更多