【问题标题】:IIS: Redirect subdomain to specific urlIIS:将子域重定向到特定的 url
【发布时间】:2017-04-26 19:58:39
【问题描述】:

在 IIS 8 中,我想将 url http://test.example.com 重定向到 http://www.example.com/abc/123

我试试这个,但不行。

<rule name="test" stopProcessing="true">
    <match url="^test.example.com$" />
    <action type="Redirect" url="http://www.example.com/abc/123" />
</rule>

【问题讨论】:

    标签: iis url-rewriting


    【解决方案1】:

    你可以像这样添加模式

    <rule name="RedirectDomain" enabled="true" stopProcessing="true">
            <match url=".*" />
            <conditions logicalGrouping="MatchAny" trackAllCaptures="true">
                <add input="{HTTP_HOST}" pattern="(.*)test.example.com />
            </conditions>
            <action type="Redirect" url="http://www.example.com/abc/123" redirectType="Permanent" />
        </rule>
    

    【讨论】:

    • 将其添加到模式中对我来说是关键:(.*)
    【解决方案2】:

    在给定端的 IIS GUI 中,您应该能够从那里选择“HTTP 重定向”,您可以输入 URL 以将站点重定向到。 我不知道是否推荐这种方法(通常用于将给定站点上的 HTTP 请求重定向到使用 HTTPS),但它会解决您的问题。

    【讨论】:

      猜你喜欢
      • 2018-02-15
      • 2017-02-20
      • 2014-03-21
      • 2012-06-01
      • 2011-11-13
      • 2014-04-06
      • 2018-05-29
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多