Redirect in Tomcat 5.5

980 views Asked by At

Is there a simple way (just configuration) to tell Tomcat 5.5 to redirect all requests coming to "abc.com" to "www.abc.com" ?

I know that it's very easy if you do that in httpd, so I wonder whether Tomcat has such a functionality built in too?

Documentation: http://tomcat.apache.org/tomcat-5.5-doc/balancer-howto.html

But there is no documentation about the format of the rules.xml file and how web.xml should look like. So any better pointers than the above documentation is already good help.

1

There are 1 answers

0
mindas On BEST ANSWER

If you are referring to the balancer documentation, does it mean that you have Apache in front already? If so, just use mod_rewrite, otherwise read on.

Normally these things are implemented using ServletFilters, but that is part of your webapp and you said want configuration-only option.

Another alternative would be to write a Valve and add it to the configuration. Here's the list of standard Tomcat valves: http://tomcat.apache.org/tomcat-5.5-doc/config/valve.html

Unfortunately, there is no valve (yet) which does what you need, but at least existing ones could be used for reference. It should be quite trivial, see its API (hint: look at invokemethod).