Forum Moderators: phranque

Message Too Old, No Replies

Redirect to different document root

info on redirecting to different document root based on subdomain

         

damiensgame

7:12 pm on Jul 25, 2009 (gmt 0)

10+ Year Member



Hello,

I have an application that uses one domain for two seperate things.

The first is a website in the front used for information and signups.

The second is a backend system that is coded.

What I need to know is how to use apache's config to set redirection to the app folder when there is a subdomain present.

For instance, I have...

/home/acctName/public_html
This is the visible site and it's info, signup, etc.

/home/acctName/application/public_html
This is the application end...it looks at the domain, pulls the subdomain and uses that as the account marker.

I am looking for a server-side look at the presence of the subdomain (non www.), and then redirect to force the application folder as the root, and not the existing as the root.

Any help is greatly appreciated. Thank you in advance!

jdMorgan

7:51 pm on Jul 25, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This is usually done by declaring the subdomain as a separate VirtualHost in httpd.conf

Jim

damiensgame

8:22 pm on Jul 25, 2009 (gmt 0)

10+ Year Member



Thanks for the quick response.

I've already started looking into virtualhost and those directives, but I am still getting a problem with all of the hosts(even without the subdomain) directed to the other directory.

NameVirtualHost *:80

<VirtualHost *:80>
ServerName servername.somedomain.com
DocumentRoot /home/subdomain/app/public_html
</VirtualHost>

when I put in somedomain.com, I get redirected to the app, and when I use dev.somedomain.com(which is a legit account name), I get an 'oops' message from the browser.

Any help is greatly appreciated, and thanks in advance.

jdMorgan

10:28 pm on Jul 25, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I don't recognize the generic "Oops" error message, so I assume that's a domain lookup error ... Have you declared dev.subdomain.com in your DNS zone file? If not, the browser won't be able to find an IP address to connect to your server.

Also see Apache virtual hosts documentation [httpd.apache.org].

Jim