Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

We have Tomcat 5.5 running behind and Apache 2.2 mod_proxy. We would like prettier URLs. For example, this is more or less how our URLs look now:   (home page)    (other parts of the web app)    (API hooks)       (misc)

We would like the publically exposed URLs to be simpler, e.g.:         (home page)      (other parts of the web app)  (API hooks)     (misc)

I know how to have Apache rewrite the incoming URLs into the longer ones Tomcat uses, but I'm concerned that this might confuse Tomcat. I am reasonably experienced with Apache but a Tomcat newbie.

Also, we want to do this with rewriting, not redirects (e.g., should not simply redirect to, as we want to keep the ugly URLs out of the address bar entirely.

share|improve this question
This sounds like a request from a pointy haired boss. "What can we do to make the URL's prettier?" Also, this one goes to eleven and can be none more black. – joeqwerty Nov 24 '10 at 18:10
@joe, simple URLs improve the usability of a site – Reid Nov 24 '10 at 18:58
How so? I understand that they make the address bar look nicer, but how do they increase or enhance the usability of a site? Giving my car a new paint job doesn't make it run any better. – joeqwerty Nov 24 '10 at 19:07

If you're rewriting everything to a common location, you would typically do something like this:

ProxyPass        / http://localhost:8080/foo/
ProxyPassReverse / http://localhost:8080/foo/

If you need different rules for different paths, you would probably use the Proxy flag on a series of RewriteRules:

RewriteRule /bar/(.*) http://localhost:8080/foo/app/bar/$1 [P]
RewriteRule /api/qux/(.*) http://localhost:8080/foo/api/qux/$1 [P]
RewriteRule /quux/(.*) http://localhost:8080/foo/quux/$1 [P]
RewriteRule /(.*) http://localhost:8080/foo/app/$1 [P]

The this will send things to the appropriate place in Tomcat.

The only complication is if the application dynamically generates URLs with fully qualified paths. In this case, you need to either fix the application, or use something like mod_proxy_html to rewrite links in your HTML content.

share|improve this answer
+1 Given proper rewrite rules Tomcat will never know what the original URLs were but only see the rewritten ones. Did this quite often with good success and mod_rewrite is the proper tool. – Axel Knauf Jul 16 '11 at 13:42

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.