FrostyGirl
asked on
Apache Subdomain DocumentRoot Pathing
Hi,
I've successfully setup a subdomain to my apache server. My trouble is that this subdomain is not routing to the correct file directory. It's instead going to the main domain's file directory. Here's the example:
www.domain.com - resolves to /web
www2.domain.com - should resolve to /web2... BUt it's resolving to /web
Config of www2.domian.com
<VirtualHost *:80>
ServerName www2.domain.com
DocumentRoot /home/www/www.domain.com/web2
<Location "/*.jsp">
JkUriSet worker ajp13:localhost:8009
</Location>
Alias /usage /var/www/usage
<Location /usage>
Allow from all
Order allow,deny
</Location>
</VirtualHost>
What have I done wrong??
Thank you tons ~Wendi
I've successfully setup a subdomain to my apache server. My trouble is that this subdomain is not routing to the correct file directory. It's instead going to the main domain's file directory. Here's the example:
www.domain.com - resolves to /web
www2.domain.com - should resolve to /web2... BUt it's resolving to /web
Config of www2.domian.com
<VirtualHost *:80>
ServerName www2.domain.com
DocumentRoot /home/www/www.domain.com/web2
<Location "/*.jsp">
JkUriSet worker ajp13:localhost:8009
</Location>
Alias /usage /var/www/usage
<Location /usage>
Allow from all
Order allow,deny
</Location>
</VirtualHost>
What have I done wrong??
Thank you tons ~Wendi
ASKER
I don't have a plesk control panel, and I don't have the following referenced config file: /var/www/vhosts/<domain.co m>/conf/vh ost.conf
have you restarted apache?
In it's simplest, I'd write this
Listen 80
NameVirtualHost *
<VirtualHost *>
ServerName www.domain.com
DocumentRoot /home/httpd/htdocs/
</VirtualHost>
<VirtualHost *>
ServerName subdomain.domain.com
DocumentRoot /home/httpd/htdocs/subdoma in/
</VirtualHost>
at the end of my httpd.conf and restart Apache.
Listen 80
NameVirtualHost *
<VirtualHost *>
ServerName www.domain.com
DocumentRoot /home/httpd/htdocs/
</VirtualHost>
<VirtualHost *>
ServerName subdomain.domain.com
DocumentRoot /home/httpd/htdocs/subdoma
</VirtualHost>
at the end of my httpd.conf and restart Apache.
ASKER
Yes
Do your DNS records for the subdomains must point to the correct IP address?
ASKER
Subdomain DNS record points to the main domain's IP.
How does your DNS entry look like?
Something like this?
domain IN A 123.22.33.45.
subdomain IN A 123.22.33.46.
Something like this?
domain IN A 123.22.33.45.
subdomain IN A 123.22.33.46.
ASKER
C:\WINDOWS\system32>nslook up
Default Server: d04.m.com
Address: 10.3.1.256
> www2.domain.com
Server: d04.m.com
Address: 10.3.1.256
Non-authoritative answer:
Name: www2.domain.com
Address: 72.xxx.18.6
Again, this is pointing to the Main webserver IP.
Default Server: d04.m.com
Address: 10.3.1.256
> www2.domain.com
Server: d04.m.com
Address: 10.3.1.256
Non-authoritative answer:
Name: www2.domain.com
Address: 72.xxx.18.6
Again, this is pointing to the Main webserver IP.
would you be willing to strip off your location and alias commands to test? make sure you restart apache
You could also try the ServerAlias directive
<VirtualHost aaa.bbb.ccc.ddd>
ServerName www.domain.com
ServerAdmin webmaster@domain.com
DocumentRoot /path/to/your/document_roo t
ServerAlias sub.domain.com
</VirtualHost>
<VirtualHost aaa.bbb.ccc.ddd>
ServerName www.domain.com
ServerAdmin webmaster@domain.com
DocumentRoot /path/to/your/document_roo
ServerAlias sub.domain.com
</VirtualHost>
Just to confirm, you're using a similar command right?
/etc/init.d/apache2 restart
/etc/init.d/apache2 restart
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Thanks for the grade
http://muffinresearch.co.uk/archives/2006/08/20/redirecting-subdomains-to-directories-in-apache/