【问题标题】:IIS and Azure Web App not picking URL Rewrite ruleIIS 和 Azure Web App 未选择 URL 重写规则
【发布时间】:2020-08-04 08:02:20
【问题描述】:

我想将一个特定的 url 重定向到另一个服务器。以下是我的重写规则:

<rewrite>
    <rules>
        <rule name="mydomain" patternSyntax="ECMAScript" stopProcessing="true">
            <match url="(http|https)(://domain1\.)(example\.)(com|net)(/research)(.*)" />
            <action type="Redirect" url="{R1}://{R3}{R4}/domain1research" />                   
        </rule>
    </rules>
</rewrite>

我希望如果用户键入https://domain1.example.com/research,他们应该被重定向到https://example.com/domain1research。我已经在 url(.com、.net 和查询字符串)上测试了具有多种变体的表达式,并且它始终匹配。但是当我运行该网站时,它永远不会被重定向到另一个页面。我在许多网络应用程序中都进行了 URL 重写,它们都工作正常。我无法将我的手指放在我在这里缺少的东西上。

我已在本地尝试使用 hosts 文件和 Azure 上已发布网站 (Asp.Net MVC) 中的条目,但没有任何效果。

【问题讨论】:

标签: iis url-rewriting azure-appservice


【解决方案1】:

根据@lex Li's blog post 和微软文档,以下重写工作:

<rewrite>
    <rules>
        <rule name="mydomain" patternSyntax="ECMAScript" stopProcessing="true">
            <match url="research" />
                <conditions logicalGrouping="MatchAll" trackAllCaptures="true">
                    <add input="{HTTP_HOST}" pattern="(domain1\.)(example\.(com|net)" />
                </conditions>
            <action type="Redirect" url="https://{C:2}/domain1research" />                   
        </rule>
    </rules>
</rewrite>

【讨论】:

    猜你喜欢
    • 2016-12-29
    • 2014-10-27
    • 2014-05-01
    • 2011-05-07
    • 1970-01-01
    • 2011-04-21
    • 2014-01-05
    相关资源
    最近更新 更多