Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question

2 Answers 2

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.

share|improve this answer

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.

share|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

Your Answer

 
discard

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.