I've tried several attempts to resolve this, but all have come up naught.

Currently I have apache setup to forward all urls at and past the /portal/ tag to tomcat. Unfortunately, tomcat receives these requests through /portal/appName, a subdirectory in webapps rather than the webapps root directory where my wars are deployed.

Is there a simple solution to this that I'm not seeing? I've been trying to use mod_rewrite to ^/portal/ $ / but that doesn't yield the expected results (perhaps I'm doing this wrong?).


With mod_jk you'll want to do something like this:-

RewriteEngine On
RewriteRule ^/(.*)$ /portal/$1 [PT]

The PT flag is needed so it Passes Through and hit's the JkMount stuff. This will rewrite everything to go to the portal context in tomcat, which is fine if you only have one application in tomcat, but if you start adding other contexts you'll need to add a RewriteCond. For full mod_rewrite documentation look at:- http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewriterule.

You'll also need to add this to your mod_jk configuration

JkOptions     +ForwardURICompat

As with all thing in apache, whilst figuring out what's going on, logging is your friend:-

RewriteLog "/var/log/apache2/rewrite.log" 
RewriteLogLevel debug

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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