i have an issue. I have a VirtualHost for domain1.com on IP, but Apache reply to the request to the IP ignoring the ServerName.

So, if i point domain2.com to i see the content of /var/www/html/domain1.com and not the content of /var/www/html/default

What is wrong?

Listen 80
SSLEngine off
DocumentRoot /var/www/html/domain1.com
ServerName www.domain1.com:80
<Directory "/var/www/html/domain1.com">
allow from all
  LogLevel notice
UseCanonicalName on

<VirtualHost _default_:80>
DocumentRoot /var/www/html/default
<Directory /var/www/html/default>
allow from all

1 Answer 1


Your use of _default_ here will match IPs that have not been defined for another VirtualHost. This means that a request to according to your config will use the first defined VirtualHost for www.domain1.com. Priority of VirtualHost are defined by their order in the config file.

To achieve the configuration you desire, move your default VirtualHost above the www.domain1.com one, and change its IP from _default_ to

Further information on the specifics of this are listed in the Apache manual which you can find at this link.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .