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 have a strange problem with the virtual hosts on my machine.

I have set one up for my domain (let's call it to accept connections on port 80 and its doc root is /var/www/websites/domain1/

Now, that one works when I go to, but now if I go to the IP of the machine, instead of going to the default document root (/var/www/) is displays the document root of (/var/www/websites/domain1/)

Im running centos5 32bit and apache2

I hope that makes sense :p

share|improve this question
Can you show us the apache config? It sounds like the document root of *:80 is also pointing to your domain1 root. – chunkyb2002 Oct 30 '10 at 19:11
I have put it here: – BytesGuy Oct 30 '10 at 20:01

IIRC as soon as you enable virtual hosts, the first virtual host takes over the configuration of some of the defaults. For example ServerName and DocumentRoot get overwritten.

Just add another vhost to the beginning of your config and set the same properties as you had before:

<VirtualHost *:80>
    DocumentRoot /var/www

<VirtualHost *:80>


I just had a look at your httpd.conf

as I think you want to use named virtual hosts (multiple host configurations on the same IP) you'll have to explicitly enable

NameVirtualHost *:80

and then the VirtualHost directives should look the same as in my example:

<VirtualHost *:80>

if you dont use named vhosts then anything served on a particular IP will come from the same virtual host configuration.

you might also want to have a look at the apache vhost documentation ( to get more familiar with the different concepts of name based vs. IP based vhosts and their respective advantages and drawbacks.

share|improve this answer
Thank you, I will give that a go :) – BytesGuy Oct 30 '10 at 20:07
Correct, first vhost is the primary/default for the IP/port. – Rob Olmos Oct 30 '10 at 20:17
Thank you for your help, I shall have a look – BytesGuy Oct 30 '10 at 20:44
I had a look and tried the suggestions, but it is still sending unhandled requests to document root. I am also using webmin if this helps – BytesGuy Oct 30 '10 at 21:15
I havent had this problem before when I have setup virtual hosts with webmin, strange :s – BytesGuy Oct 30 '10 at 21:21

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.