We have hosted a Java web application for www.domain.com on Apache & Tomcat.

I have two problems, as follows

1) Directory Index in Apache lists home.jsp ahead of redirect.jsp. For my domain.com in the web.xml, I have maintained redirect.jsp as the welcome file. However, when I visit www.domain.com, home.jsp is being rendered.

2) In an attempt to resolve problem 1 above, I maintained an entry in htaccess - DirectoryIndex redirect.jsp. Though this resolves the above problem, this creates a different problem for me, as follows.

Subdomains on domain.com need to be redirected to home.jsp of a different domain abc.com. The problem that is happening now is that when I try to access xyz.domain.com, though it is being redirected to abc.com, but the redirect.jsp page of abc.com is being rendered when actually home.jsp should be rendered. So, it seems the htaccess directory index is being carried forward to abc.com

I need to know what I am doing wrong & what is the best way to set this up on Apache & Tomcat.


Maintain your DirectoryIndex home.jsp.

To solve your #1 problem, instead of putting DirectoryIndex redirect.jsp in the htaccess of www.domain.com, use ModRewrite instead:

RewriteEngine On
RewriteRule ^$ redirect.jsp

(I only tested this in PHP environment, but should work if you have mod_rewrite in your Apache)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.