I currently have a few sub domains and a main domain.

My sub domains are set as "A-records" pointing to the VPS server. However I have tried making seperate Virtual host but when I access all sub domains they link to one directory which is the main.

How do I get each sub domain to point to there correct directory on my VPS? I have tried the virtual host however the problem is still there.

Here is my try:

<VirtualHost *:80>
    ServerAdmin hub@xxxxxxxxxxxxxxx.net
    DocumentRoot /var/www/html/hub/
    ServerName www.hub.cxw.org
    ErrorLog logs/dummy-hub.cxw.org-error_log
    CustomLog logs/dummy-hub.cxw.org-access_log common
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin hub@xxxxxxxx.net
    DocumentRoot /var/www/html/cxw/
    ServerName www.cxw.org
    ErrorLog logs/dummy-cxw.org-error_log
    CustomLog logs/dummy-cxw.org-access_log common
</VirtualHost>

Help please.

link|improve this question
feedback

2 Answers

up vote 0 down vote accepted

Remove the trailing slash from DocumentRoot. There appears to be a bug in mod_dir which causes problems when the DocumentRoot has a trailing slash (i.e., "DocumentRoot /usr/web/") so please avoid that.

Also, your seem to have your main directory as a parent to your vhosts. This is not a very effective setup as people can go to your main site and then navigate down into your subdomains which isn't usually what you want. I say this as you lack any <Directory> directives in your vhosts.

link|improve this answer
feedback

Have you enabled the NameVirtualHost *:80 directive somewhere in your apache config? Also, you'll need to restart apache for any of these changes to become active.

link|improve this answer
Hi, yes I have enabled that. I dont understand the problem still. All the sub domain + main domain reads of one directory :S ... – Asus Jun 14 '11 at 17:42
I have tried alot of things, they all seem to direct into one directory :S. – Asus Jun 14 '11 at 17:49
feedback

Your Answer

 
or
required, but never shown

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