【发布时间】: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 由于某些未知原因将 ? 切换为 &
我也在UrlRewriteFilter repository on Google Code上发布了这个问题。
有什么建议吗?
【问题讨论】:
标签: tomcat redirect url-redirection tuckey-urlrewrite-filter fqdn