Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

I set up a subdomain and got it running, but now when I go to, it points to's directory. In other words, instead of going to /var/www/html it points to /var/www/test

I haven't altered httpd.conf other than adding this at the very bottom for the subdomain:

NameVirtualHost *:80

<VirtualHost *:80>
    DocumentRoot "/var/www/test/"

How can I fix httpd.conf so the normal domain points to /var/www/html and the subdomain continues to point to /var/www/test ?


share|improve this question
up vote 1 down vote accepted

Because when using virtual hosting, the "main host goes away". See , specifically the note "Main host goes away".

So, in your case, simply duplicate your VirtualHost container and configure it for a ServerName of with a DocumentRoot of /var/www/html .

share|improve this answer
Thanks, that's all it needed! – user1062058 Sep 25 '12 at 12:53

If this is the only vhost that you have configured then this is expected behaviour. Apache will serve up the requested domain or the default domain. Without an explicit default/catch-all domain the first vhost that apache processes is served.

If you want to serve up you need to create a vhost for it

<VirtualHost *:80>
    DocumentRoot "/var/www/"

and then restart the httpd service.

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.