Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When I use the following code:

<VirtualHost *>
ServerName subone.domain.tld
DocumentRoot /var/www/subdomain/subone/

<VirtualHost *>
ServerName subtwo.domain.tld
DocumentRoot /var/www/subdomain/subtwo/

Every query goes to /var/www/subdomain/subone. Including: domain.tld, subone.domain.tld, subtwo.domain.tld, ...

When I add a "NameVirtualHost *" to the beginning of the file, everything goes to /var/www

What am I doing wrong?

share|improve this question
up vote 4 down vote accepted

I think you are missing the port numbers maybe? e.g. NameVirtualHost *:80

and VirtualHost *:80

share|improve this answer
I thought those were implied? I've added it just in case. I also didn't have a "ServerName", adding that changed the behavious aswel. – skerit Jan 11 '10 at 21:38
It's not implied. Also, ensure that <VirtualHost *:80> matches whatever you have defined as NameVirtualHost. Example: NameVirtualHost *:80 – Joe Jan 11 '10 at 22:03

In my opinion your are missing this entry in your httpd.conf
NameVirtualHost ip_of_your_server:80


share|improve this answer

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.