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

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 / http://myweb.newdomain.com/

Tomcat is running and handling all requests sent to http://myweb.olddomain.com:8080/...
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     http://myweb.olddomain.com:8080/   to    http://myweb.newdomain.com:8080
http://myweb.olddomain.com:8080/mydir       to    http://myweb.newdomain.com:8080/mydir
from    http://myweb.olddomain.com:8080/mydir/foo.jsp  
to        http://myweb.newdomain.com:8080/mydir/foo.jsp
from    http://myweb.olddomain.com:8080/mydir/foo.jsp?filter=XXX      
to        http://myweb.newdomain.com:8080/mydir/foo.jsp?filter=XXX

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 /0.0.0.0:8009
Nov 17, 2008 3:44:49 AM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/22  config=null

Thanks!
bohunk24Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

caterham_wwwCommented:
> perhaps using mod_rewrite

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

Did you already try the UrlRewriteFilter with


<rule>
<name>redirect olddomain</name>
<condition name="host" operator="notequal">myweb\.newdomain\.com:8080</condition>
<from>^/(.*)</from>
<to type="redirect">http://myweb.newdomain.com:8080/$1</to>
</rule>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
bohunk24Author Commented:
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">http://myweb.newdomain.com:8080/subdir/$1</to
P.S. In answer to your question, yes, myweb.olddomain.com:8080 connects to Tomcat.  I don't need apache for that.  
 
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java App Servers

From novice to tech pro — start learning today.