How do I redirect JSP webapps handled by Tomcat to another server/domain?

Posted on 2008-11-17
Last Modified: 2013-12-02
I am planning a migration from our current server (Sun OS 5.8) to our new server (Redhat 4 64-bit).  I have recreated a similar infrastructure on the new server - Apache2, Tomcat, MySQL, Twiki.

On the current server I am running Apache 2.0.49 and Tomcat 5.0.24
On the new server I am running Apache 2.0.52 and Tomcat 5.5.25
On each machine I am using default ports: port 80 for Apache and 8080 for Tomcat.

All the pieces on the new server are working fine and accessing stuff only in the new environment.

My problem is to seamlessly redirect any links/references to the old domain/server to the new one, for both Apache2 (port 80) and for Tomcat (port 8080).

On the old server, I know I can add a redirect in apache's httpd.conf to redirect all apache
requests (for documents and cgi-bin scripts) to the new server and that seemed to work fine:
AllowOverride All
Redirect permanent /

Tomcat is running and handling all requests sent to
What I need is to also redirect those tomcat webapp requests.  And I just want the simplest, easiest way to do so.  Speed or load is not an issue.
I want all of these type of references to redirect smoothly:
from   to       to

I've searched forums and found lots of suggestions using a variety of techniques,
but have not been successful.  I'm not very familiar with mod_rewrite, mod_jk, 301 redirection, etc. but am learning slowly.
I was also experimenting with Paul Tucke's URLRewriteFilter, but couldn't get that to work
(it would not match any of my "from" expressions).
It seems to me that this shouldn't be that complicated hard, but I'm finding it very confusing and frustrating.  I think I should be able to do it perhaps using mod_rewrite, but I get tangled trying to determine specifically what I need to add to accomplish that.

What would you recommend as the easiest way to get all of these redirections to occur
from an old server in one domain to a new server in another domain?

I've reverted to what was the original conf files for apache and for tomcat (without any of my additions).
When I start up tomcat, I see the following in the catalina.out file:
Nov 17, 2008 3:44:49 AM org.apache.coyote.http11.Http11BaseProtocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
Nov 17, 2008 3:44:49 AM org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /
Nov 17, 2008 3:44:49 AM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/22  config=null

Question by:bohunk24
    LVL 27

    Accepted Solution

    > perhaps using mod_rewrite

    If is a tomcat application server, you can't use apache's modules here. Or does connect to tomcat?

    Did you already try the UrlRewriteFilter with

    <name>redirect olddomain</name>
    <condition name="host" operator="notequal">myweb\.newdomain\.com:8080</condition>
    <to type="redirect">$1</to>

    Open in new window


    Author Comment

    Thank you Caterham!  That was the clue I needed!
    I had tried all sorts of permutations on URL rewrite rules.  However, I didn't include any conditions since the documentation led me to believe I didn't need them and that I could do everything in the regular expression of the "from".
    Your suggestion worked perfectly for webapps/ROOT.  I did need to modify it slightly for the other subdirectories in webapps.  While I was able to use the same <from> in the urlrewrite.xml, but had to add the directory name to the <to>, e.g. <to type="redirect">$1</to
    P.S. In answer to your question, yes, connects to Tomcat.  I don't need apache for that.  

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Join & Write a Comment

    As Wikipedia explains 'robots.txt' as -- the robot exclusion standard, also known as the Robots Exclusion Protocol or robots.txt protocol, is a convention to prevent cooperating web spiders and other web robots from accessing all or part of a websit…
    Hi, in this article I'm going to teach you how to run your own site, and how to let people in (without IP). I'll talk about and explain each step... :) By the way, everything in this Tutorial is completely free and legal. This article is for …
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now