0

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?

Mario
  • 465
  • 2
  • 7
  • 16

2 Answers2

1

This is a known issue in UrlRewriteFilter, see the release notes here:

Appending query strings breaks URL [UPDATE] Which you mentioned in your last sentence as I just saw...shame on me

Although the release notes say it it fixed in 4.0.5, there is no such version in any public maven repo, and the SVN trunk is still on 4.0.5-SNAPSHOT.

Matthias M.
  • 211
  • 3
  • 7
1

I faced similar issue. I could get it to work by appending a ? end of the "to" url. Something like this http://myIntranet.domain.com/$1?