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

I have a few Tomcat installs where there is only a single main application on them (in addition to things like Manager). Other than just changing the default Tomcat homepage to include a redirect to the app, is there a better way? Or, one better, how can I map to just and leave the other apps (like Manager) alone?

share|improve this question
up vote 3 down vote accepted

Install the app to be the ROOT context.

That could be done by:

  1. deploying the war file as ROOT.war,
  2. deploying the exploded war file in the webapps/ROOT directory,
  3. deploying the app to the path "/" via the Tomcat manager,
  4. adding a Context section to your Tomcat configuration: <Context path="/" docBase="${catalina.home}/webapps/app"/>
share|improve this answer
When doing this on a default Tomcat install you may have to remove the default ROOT.war that comes with Tomcat. You can still leave the manager application but you'll need to remove the default / context first. – Jeremy Bouse Sep 12 '09 at 14:19

I pretty much always stick an Apache in front of a Tomcat and connect via AJP (either mod_proxy_ajp or mod_jk) because Tomcat is so incredibly inefficient at serving static content and because of the exact problem you describe. Also, by sticking a front end on, you can protect /manager and any other apps with rewrite rules. /manager is also a frequent source of attack, and this technique prevents the outside world from reaching it completely.

To create a redirect like you are describing, create a rewrite rule to the effect of:

    # if the URL doesn't go to /myapp /admin /jkstatus /server-status or /awstats, redirect to /myapp
    RewriteCond %{REQUEST_URI} !^/myapp
    RewriteCond %{REQUEST_URI} !^/admin
    RewriteCond %{REQUEST_URI} !^/jkstatus
    RewriteCond %{REQUEST_URI} !^/server-status
    RewriteCond %{REQUEST_URI} !^/awstats
    RewriteRule .* /myapp [R,L]

I'm sure something like this can be done at the Tomcat layer, but my preference is to keep the Tomcat portable and simple and create any rules like this at the Apache level.

If you do this, don't forget to JkUnmount or exclude via proxy_ajp your static content so that it is served from the Apache.

share|improve this answer
This works only if your application does not attempt to put it's context into any URLs the app produces... If anywhere in the app it generates URLs using the Tomcat application context the URLs will have /myapp in them and it will not appear as coming from / as the original question wished. – Jeremy Bouse Sep 12 '09 at 14:17

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.