Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I am writing a website using Railo. My code is to be deployed on a Railo Server running on Tomcat, overlayed on a regular Apache+PHP server.

I need to send all requests to and its child files to the directory /public_html/railo/tomcat/webapps/ROOT/subdomain/ directory.

I defined a subdomain in cPanel, with the document root as /public_html/railo/tomcat/webapps/ROOT/subdomain/, but still requests to display files in /public_html/railo/tomcat/webapps/ROOT/. I can view my files if I request

I've been fiddling with the .htaccess files for quite some time now, but I'm stuck

Is there any way I can do what I'm trying to achieve, or am I resigned to get those pages using

share|improve this question

1 Answer 1

Put the following into /public_html/railo/tomcat/webapps/ROOT/.htaccess:

RewriteEngine on
RewriteCond %{HTTP_HOST}
RewriteRule (.*) /public_html/railo/tomcat/webapps/ROOT/lfEnterprise$1

Here the target of the RewriteRule is a filesystem path, not a URL as is more common. RewriteRule will accept either, and figure out which one is meant. Please see the RewriteRule documentation for that and more.

share|improve this answer
Where do I put this htaccess? in the ROOT directory? – Pranav Hosangadi Nov 11 '11 at 7:21
Edited to clarify that. – Andrew Schulman Nov 11 '11 at 7:26
So let me demystify things a bit... My subdomain is but my app resides in /public_html/railo/tomcat/webapps/ROOT/lfEnterprise Also this is a Tomcat server overlayed on an Apache, so please keep that in mind. – Pranav Hosangadi Nov 11 '11 at 7:33
Edited again. I don't know Tomcat, but I don't think it matters here. – Andrew Schulman Nov 11 '11 at 12:07
Edited again to remove one of the RewriteConds. – Andrew Schulman Nov 11 '11 at 12:22

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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