[CLUE-Tech] apache redirect to another directory on same server.

David Anselmi anselmi at americanisp.net
Tue Jul 1 20:19:33 MDT 2003


Jeffery Cann wrote:
> I have tomcat4 running underneath apache 2.0.46.  I want to redirect clients 
> from / to /webapp/index.jsp.  (Since I am using Tomcat (serving a J2EE web 
> application, I cannot simply change the DocumentRoot).

Why?  Obviously you don't want Apache serving out of /.  You want it 
serving out of /webapp which is what the doc root is for.  Seems like 
that's what the appBase part of the host element is for in Tomcat's 
conf/server.xml.

> But, I tried this:
> 
> 	Redirect permanent /    /webapp/index.jsp
> 
> but apache complianed that /webapp/index.jsp is not a URI.  If I do this:
> 
> 	Redirect permanent /    http://www.example.com/webapp/index.jsp
> 
> it results in an infinite redirect loop.

This is because the redirect applies to everything below / (which is, 
well everything).  Probably you want Alias instead, though the docs 
don't make it obvious (they refer to mapping directories from outside 
the document root to URLs that are in it -- but it works for your case too).

The reason Alias doesn't loop is that Apache does the translation 
internally figuring out what to serve to your request.  With Redirect 
the browser makes a new request that is subject to redirection.

HTH,
Dave




More information about the clue-tech mailing list