I would like to redirect all traffic (with all parameters etc.) coming from pattern http://myIntranet/*
to http://myIntranet.domain.com/*
I set up the following configuration in 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>
This is ok for this case types:
when you go to http://myIntranet/
, you are being redirected to http://myIntranet.domain.com/
But when you go to http://myIntranet/something/viewpage.action?pageId=529509
it's not good because it ignores some part of suffix tu base URL. I would like it to redirect to http://myIntranet.domain.com/something/viewpage.action?pageId=529509
Any suggestions?
Edit:
I found the solution. I just needed to add qsappend="true"
in the to
tag like this:
<to type="redirect" last="true" qsappend="true">http://myIntranet.domain.com/$1</to>
With this configuration and calling URL:
http://myIntranet/something/viewpage.action?pageId=529509
I get:
http://myIntranet.domain.com/something/viewpage.action&pageId=529509
Now, the problem is that UrlRewriteFilter for some unknown reasons switches ?
with &
I also posted the problem on UrlRewriteFilter repository on Google Code.
Any suggestions?