Redirect in Tomcat 5.5 [closed]
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this questionIs 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开发者_JS百科 look like. So any better pointers than the above documentation is already good help.
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 ServletFilter
s, 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 invoke
method).
精彩评论