【问题标题】:UrlRewriteFilter switches ? with &UrlRewriteFilter 开关?和 &
【发布时间】:2014-03-28 08:20:26
【问题描述】:

我想将来自模式http://myIntranet/* 的所有流量(包括所有参数等)重定向到http://myIntranet.domain.com/*

我在 urlrewrite.xml 中设置了以下配置:

    <rule>
        <name>Canonical Hostnames</name>
        <note>
            The goal of this rule is to force the use of a particular hostname, in preference to other hostnames which
            may be used to reach the same site. For example, if you wish to force the use of www.example.com instead of
            example.com, you might use a variant of the following recipe.

            RewriteCond %{HTTP_HOST} !^fully\.qualified\.domain\.name [NC]
            RewriteCond %{HTTP_HOST} !^$
            RewriteRule ^/(.*) http://fully.qualified.domain.name/$1 [L,R]
        </note>

        <condition name="host" operator="notequal">^myIntranet\.domain\.com</condition>
        <condition name="host" operator="notequal">^$</condition>
        <from>^/(.*)</from>
        <to type="redirect" last="true">http://myIntranet.domain.com/$1</to>

    </rule>

这对于这种情况类型是可以的: 当您转到 http://myIntranet/ 时,您将被重定向到 http://myIntranet.domain.com/

但是当您转到http://myIntranet/something/viewpage.action?pageId=529509 时,它并不好,因为它忽略了后缀 tu 基本 URL 的某些部分。我希望它重定向到http://myIntranet.domain.com/something/viewpage.action?pageId=529509

有什么建议吗?

编辑:

我找到了解决方案。我只需要在to 标签中添加qsappend="true",如下所示:

<to type="redirect" last="true" qsappend="true">http://myIntranet.domain.com/$1</to>

使用此配置和调用 URL:

http://myIntranet/something/viewpage.action?pageId=529509

我明白了:

http://myIntranet.domain.com/something/viewpage.action&pageId=529509 

现在,问题是 UrlRewriteFilter 由于某些未知原因将 ? 切换为 &amp;

我也在UrlRewriteFilter repository on Google Code上发布了这个问题。

有什么建议吗?

【问题讨论】:

    标签: tomcat redirect url-redirection tuckey-urlrewrite-filter fqdn


    【解决方案1】:

    这是 UrlRewriteFilter 中的一个已知问题,请参阅此处的发行说明:

    Appending query strings breaks URL [更新] 你在最后一句话中提到的,正如我刚刚看到的那样......我感到羞耻

    虽然发行说明说它是 fixed in 4.0.5,但在任何公共 maven 存储库中都没有这样的版本,SVN trunk 仍在 4.0.5-SNAPSHOT 上。

    【讨论】:

      【解决方案2】:

      我遇到了类似的问题。我可以通过附加一个 ? “到”网址的结尾。像这样http://myIntranet.domain.com/$1?

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2015-04-20
        • 2012-03-18
        • 1970-01-01
        • 1970-01-01
        • 2011-03-24
        • 1970-01-01
        • 1970-01-01
        • 2011-04-14
        相关资源
        最近更新 更多