1

I have a Tomcat 7 running on CentOS.

Given is a configuration where I have my webapp "foo" placed in webapps/foo.war. I can access it without any problems using http://host.name/foo.

Now I want to get access to the same webapp using a 2nd URL - "http://host.name/bar".

Setting up a webserver in front of my Tomcat is not an option so I need something like mod_rewrite for Tomcat.

What I have tried so far is to setup another context like this:

<Context path="/bar" docBase="foo"/>

At first it seems to work, but at the second look it shows that this isn't actually an "alias" - it is a second instance from my webapp which really is not a valid option for me.

So... does anybody know how to get some kind of aliasing or URL rewriting for Tomcat?

Pascal Schmiel
  • 1,738
  • 12
  • 17

3 Answers3

1

There is something similar to mod_rewrite for servlet containers called URL Rewrite. Taken from SO.

fuero
  • 9,591
  • 1
  • 35
  • 40
1

In your special case, what about setting a symlink in your webapps directory?

Asume your directory looks like this:

ls webapps/
foo  foo.war

Just add a symlink to foo with the name bar:

ln -s foo bar

Getting this:

ls webapps/
foo  bar  foo.war
Christian
  • 4,703
  • 2
  • 24
  • 27
  • 3
    looks like a great idea. sad news: with a symlink in my webapps directory I get a second webapp instance too ("bar" directory in work/Catalina/localhost/) – Pascal Schmiel May 03 '13 at 13:41
0

You might be able to find (a few exist) or write a small Java web app that reverse proxies from one URL pattern to another. See https://github.com/ahabra/reverse-proxy.

msinatl
  • 36
  • 2