user854894
user854894

Reputation:

Shortening URLs for GWT/Tomcat app

I have a GWT app deployed as webapps/ROOT ( context [] ). A typical URL looks like:

http://example.com/?id=abc

What I want is a URL that looks like http://example.com/abc

Ideally not just a redirect, but this latter form will stay in the browser's URL bar ( a la mod_proxy, or mod_rewrite with [P] ).

The problem is, while I can use mod_rewrite rules to to a redirect, the URL in the location bar changes. If I try to use mod_proxy or mod_rewrite with [P], The query string part of the destination doesn't seem to make it across.

Here is my proxy ([P]) rule

RewriteCond %{REQUEST_URI} /([a-zA-Z0-9]+)
RewriteRule ^/([a-zA-Z0-9]+)$ http://example.com/?id=%1 [P]

What seems be to happening here is http://example.com/abc is getting redirected to http://example.com/ ( no query string part ). If I remove [P] above, it works, but the location bar changes to the destination.

Some docs seem to imply that mod_proxy CAN'T pass the query string, is that correct? If so, How can I achieve my goal? I'm open to literally anything, be it custom servlet, filter, apache config, mod_jk setting, whatever. I've been stuck on this for days. Thanks.

Upvotes: 0

Views: 214

Answers (1)

David Levesque
David Levesque

Reputation: 22451

Did you try with the [QSA] flag instead of the [P] flag ?

See: http://httpd.apache.org/docs/current/rewrite/flags.html#flag_qsa

Upvotes: 0

Related Questions