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 have a root server where i have apache2 running with some virtualhost configs handling 2 of my domains with some subdomains.

i realized if i try to access some url which is configured in my virtualhosts, then i get one of my configured virtualhosts shown.

For example i have a webmail client set up on Now if i type something like, then it shows my webmail client. There is absolutely nothing pointing to my webmail client or anything related to Why is that happening?

share|improve this question
up vote 2 down vote accepted

For requests that come in with no Host: header, or one that doesn't match the ServerName or ServerAlias of any of the enabled VirtualHosts, apache will serve the request from the first vhost it loaded.

To work around this situation, create a "default" vhost that gets loaded before all the others. The configuration of that vhost would be something like:

<VirtualHost *:80>
        ServerAdmin webmaster@localhost

        Redirect 404 /
        ErrorDocument 404 "Site not found."

This will display a 404 error for any non-matching requests.

share|improve this answer
I still wonder if there is any non-workaround way to do it.. – Karma Fusebox Feb 2 '13 at 16:07
@KarmaFusebox - I've never seen one. – EEAA Feb 2 '13 at 16:21

If no ServerName matches the given domain then simply the first vhost that was read when firing up apache is displayed. I'm not aware of any possibility to disable this behaviour. A hacky workaround is to make sure a dummy vhost is read before all other VirtualHost blocks.

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.