【问题标题】:IIS URL Rewrite not working when trying to redirect sub domain to domain with query string尝试使用查询字符串将子域重定向到域时,IIS URL 重写不起作用
【发布时间】:2020-09-04 03:35:52
【问题描述】:

在我看来,IIS URL 重写是一项简单的任务。

我需要基于子域重定向到带有查询字符串的主域。例如

demo.domain.com 需要重定向到www.domain.com/?key=demo

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
    <rewrite>
            <rules>
                <rule name="Redirect" stopProcessing="true">
                    <match url="(.*)" />
                    <conditions trackAllCaptures="true">
                        <add input="{HTTP_HOST}" pattern="demo.domain.com" />
                    </conditions>
                    <action type="Redirect" url="www.domain.com/?key=demo" appendQueryString="false" redirectType="Found" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

【问题讨论】:

标签: redirect iis url-rewriting


【解决方案1】:

当您对 demo.domain.com 进行数字化时会发生什么?

尝试像这样更改您的代码:

<rules>
    <rule name="Redirect" stopProcessing="true">
        <match url="(.*)" />
        <conditions trackAllCaptures="true">
            <add input="{HTTP_HOST}" pattern="^demo\.example\.com$" />
        </conditions>
        <action type="Redirect" url="http://www.example.com/?key=demo" appendQueryString="false" redirectType="Found" />
    </rule>
</rules>

查看“添加输入=”和“操作类型=”行的变化

【讨论】:

    猜你喜欢
    • 2018-07-28
    • 1970-01-01
    • 1970-01-01
    • 2016-11-01
    • 1970-01-01
    • 2019-11-17
    • 2013-10-16
    • 1970-01-01
    • 2014-05-10
    相关资源
    最近更新 更多