Sign up ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I am trying to remove the context name from the URL of my server.

Current URL -

What I need to make is to make it available at -

So it is only going to host one main app and that needs to be displayed when we open on browser.

I have already tried couple of things like below -

RewriteEngine On
RewriteCond %{REQUEST_URI} !^/(Context/.*)$
RewriteRule ^/(.*)$ /Context/$1 [P,L]


redirect permanent /MyApp/ abcd://


Using JKMount -

JkMount /MyApp/* ajp13
JkMount /MyApp* ajp13


Deploy war file to ROOT of tomcat and make relevant chagnes in web and server.xml All of these aren't working and I keep getting a intenal error. I need a way to basically trim the tomcat URL to make short.

share|improve this question

migrated from Feb 21 '11 at 21:42

This question came from our site for system and network administrators.

Is there a link with ""? I mean do you plan to do other rewrite rules for other domains that will use your app too? – Olivier Pons Nov 19 '11 at 6:27

2 Answers 2

Assuming that works as is... shouldn't you be able to just use your final RewriteRule? Just drop the RewriteCond and the 'P' flag.

Or if you're going to use mod_rewrite to do the proxy with the 'P' flag, don't you need to use the full URL in the RewriteRule? Something like http://tomcatserver:tomcatport/Context/$1

share|improve this answer
@matthew Thanks Matthew though I did try with following as per your suggestion though it doesn't seem to have worked out - RewriteRule ^/(.*)$ /Foldername/$1 [P] Instead of (.*), I used following - RewriteRule ^/(/.*)$ /GroupAGWeb/$1 [P] OR RewriteRule ^/(*)$ /Foldername/$1 [P] – Redbull Fan Feb 18 '11 at 4:52
I don't think you want the P flag. If you've set up the Proxy with Mod_jk I don't think you also need to tell mod_rewrite to do the proxy. – matthew Feb 21 '11 at 12:38

You should stop using mod_jk and start using mod_proxy. I run tomcat on port 8080. The web app that powers my site has an internal url like http://localhost:8080/mysite I use mod proxy to make it available at I use a firewall to ensure that only port 80 is accessible from the outside world. mod_proxy is much more flexible than mod_jk. Tomcat makes application available both http port 8080 and through the ports that mod_jk uses by default, so you likely won't even have to change your tomcat settings.

My apache configuration looks like this for that site

<VirtualHost *:*>
    ProxyRequests Off
    ProxyPass / http://localhost:8080/mysite/
    ProxyPassReverseCookiePath /mysite /
    ProxyPassReverseCookieDomain localhost

The cookie stuff is so that session cookies get translated by mod_proxy correctly. You can also have mod_proxy rewrite the links if you need to. In my case, my web app handles that.

share|improve this answer

Your Answer


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