Apache2 Virtual Host broken; displayed default index.html on subdomain, but correct content on www.subdomain

Solution 1:

I experienced the exact same problem and eventually what solved the problem was when I disabled the default site in apache by unlinking it from sites-enabled:

sudo unlink /etc/apache2/sites-enabled/000-default

After doing this, all my sites displayed correctly. I see this question is quite old, but hope this can help someone else out there.

Solution 2:

The solutions of the other posters will do it.

You "it Works" is shown, becase all your Virtuall Host match to localhost. And if you call "client1.example.com" apache will skipp the localhost Vhosts and if there is no matching Vhost, it will use se default config.

Do what the other posters told (change your vitial hosts to <VirtualHost *:80> of <VirtualHost *> of change your default vhost to the Document root you like.

Don`t forget: even if you define your Vhosts correctly, the server will call the default site if some one requests your server without a hostname (e.g. via ip address).