+2  A: 

A 301 sounds like the appropriate response if you really want to redirect, but maybe you really wanted to proxy the requests so that the client was unaware of the redirect? In this case, take a look at using mod_proxy as a reverse proxy.

Paul Dixon
A: 

Your httpclient in java needs to properly handle 301 answers. If it does not, it is broken. If you don't want or can't, then using mod_rewrite/mod_proxy as indicated by Paul to "transparently" redirect is the way to go. See here

Keltia
+2  A: 

Another option additional to the already given mod _ proxy is mod _ jk. (sorry for the spaces, otherwise formatting is messed up)

Both are apache extensions that allow apache to consume the request, transparently forward it to tomcat, wait for the response and then send the result back.

IMHO mod_jk has a few advantages

  • Tomcat automagically gets the served hostname, protocol and port (with mod_proxy you have to configure the fact that it's proxied in the Connector, see the options proxyName and proxyPort
  • mod_jk provides loadbalancing - should you need this
  • apache speaks to tomcat in a protocol designed for this task (ajp13). With mod_proxy they talk http, which has a slightly higher overhead (Disclosure: I've never measured it myself, just parrotting it)

What you use in the end is completely your choice - it's not that much a difference between both options. (Someone correct me if it is)

Configuration is as follows (untested pseudocode. Do read the docs, please understand what you do...)

# somewhere in httpd.conf, above the virtual hosts
JkWorkersFile /etc/apache2/workers.properties
JkLogFile     /var/log/apache/mod_jk.log
JkLogLevel    error

# your existing part with virtual hosts
<VirtualHost ...>
   ....
   JkMount /Lang/* tomcat1
   JkMount /Lang   tomcat1  # if you need the directory itself also to be forwarded
   ....
</VirtualHost>

# the workers.properties file described above
# 'tomcat1' is the reference used above as argument to JkMount
workers.list=tomcat1
worker.tomcat1.port=8009
worker.tomcat1.host=localhost
worker.tomcat1.type=ajp13
worker.tomcat1.lbfactor=1
Olaf
thanks for noting the advantages of mod_jk
cherouvim
A: