Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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 recently got my domain name working fine with my server and managed to get subdomains pointing to specific folders. However I have just noticed a little problem. I have my /etc/apache2/sites-enabled/000-default set to:

<VirtualHost *:80>
        VirtualDocumentRoot /local/www/%1
        ServerName *.dev.localhost

and when I go to it displays the content of /local/www/test/ and that's great. However, I mistyped the domain and realise that is also doing the exact same thing when you miss out the .dev.part. I don't want this to happen. Can anybody suggest any fixes?

share|improve this question


  • The VirtualHost block above is the first one in your configuration, and
  • There is no explicit match for, e.g.,

...then Apache will use the above VirtualHost block for That is, in the absence of an explicit match, Apache will use the first VirtualHost definition it finds. From the documentation:

If no matching ServerName or ServerAlias is found in the set of virtual hosts containing the most specific matching IP address and port combination, then the first listed virtual host that matches that will be used.

share|improve this answer
But I do have another VirtualHost block directly above it yet it's not taking that one on. – andy Aug 13 '12 at 12:39
Well, then this probably isn't the problem. What does the previous VirtualHost block look like? – larsks Aug 13 '12 at 12:42
It's one that makes point to /local/www/static – andy Aug 13 '12 at 12:47
up vote 0 down vote accepted

Solved the question:

<VirtualHost *:80>
    VirtualDocumentRoot /local/www/%1
    ServerAlias *

By using ServerAlias.

share|improve this answer

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.