When you have virtual hosts configured on a port, one of them will always serve a request for that port - the main server isn't used anymore, a request that doesn't match the ServerName
or ServerAlias
of a <VirtualHost>
will get sent to the first <VirtualHost>
on the port. The only way the DocumentRoot
that you've defined globally will be used at all is if the <VirtualHost>
that handles a request doesn't define its own DocumentRoot
.
From the documentation:
Main host goes away
If you are adding virtual hosts to an existing web server, you must also create a <VirtualHost>
block for the existing host. The ServerName
and DocumentRoot
included in this virtual host should be the same as the global ServerName
and DocumentRoot
. List this virtual host first in the configuration file so that it will act as the default host.
Set yourself up a <VirtualHost>
to handle the requests that you're trying to send to the main server's DocumentRoot
- if you're accessing it by IP, just set the vhost to have a ServerName
of that IP address.