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

I have been battling this weird problem for hours. I think I have all files in order and things should work, but they do not. I have

  • (alias:

This should be two different websites.

These are my config files (Ubuntu 10.04):


Include /etc/apache2/sites-enabled/ 
Include /opt/subdomain.conf


Listen 80


    DocumentRoot /home/landing/www
    <Directory /home/landing/www>
        Options None
        AllowOverride None

--> NOT specitying a ServerName. Catches requests to the IP, and indeed opens /home/landing/www


    DocumentRoot /home/domain1/www
    <Directory /home/domain1/www>
    Options None +FollowSymLinks
        Order Allow,Deny
        Allow from All

--> This is for the main site. Opens fine, also with


DocumentRoot "/opt/subdomain/www"

--> Here is the problem. This does NOT open. It opens /home/landing/www instead...? This happens when I open ANY subdomain, so this whole config appears ignored. Anybody any idea why? Or how to check??

share|improve this question
is /opt/subdomain.conf readable by the apache user? – Kenny Rasschaert Jan 27 '11 at 18:49

1 Answer 1

up vote 0 down vote accepted

As far as I can see this is due to not using ServerName in your first VirtualHost.

You can't mix up name and non-named based Virtual Hosting in apache, it confuses the hell out of it, apache will do the "best effort" to match a domain, following the configuration order.

The recommended way to make a default virtualhost is still to have a ServerName in it (as it should be) but change the VirtualHost line from

    DocumentRoot /home/landing/www

to this

<VirtualHost _default_:80>
    DocumentRoot /home/landing/www
    ServerName blablabla
share|improve this answer
Thanks! This did the trick. But I did NOT put a ServerName for default. Because this is supposed to be the 'catch-all' for any request for a site not configured, right? (say I type the IP instead of a site, then this should handle it?). So then I do not see what I should put for servername. And although my problem is now fixed, in fact when I put my IP I am being forwarded to /home/domain1/www, so still quite odd. But the problem is fixed. I will try to learn more about the deafult domain... Thanks for your help! – user60129 Jan 27 '11 at 20:41

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.