0

我想将来自模式的所有流量(带有所有参数等)重定向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

有什么建议么?

编辑:

我找到了解决方案。我只需要像这样添加qsappend="true"标签to

<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 出于某些未知原因切换?&

我还在Google Code 上的 UrlRewriteFilter 存储库上发布了问题。

有什么建议么?

4

2 回答 2

1

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

于 2015-04-14T23:25:52.200 回答
1

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

附加查询字符串会破坏 URL [更新] 你在上一句中提到的,正如我刚刚看到的那样……真为我感到羞耻

虽然发行说明说它已在 4.0.5 中修复,但任何公共 maven 存储库中都没有这样的版本,SVN 主干仍在 4.0.5-SNAPSHOT 上。

于 2014-06-11T14:40:49.577 回答