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

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 am trying to configure apache2 to have the following virtualhosts:

  • One that serves requests for
  • Another one that servers requests for anything else

How do I go about doing this?

share|improve this question
up vote 2 down vote accepted
  1. Have a NameVirtualHost *:80 directive, and define both VirtualHost blocks as <VirtualHost *:80>
  2. Put your "anything else" vhost first in the config (or alphabetically first in an included directory) with any ol' ServerName - it'll get all requests that don't match the other host - and your vhost with ServerName second.

That's all!

share|improve this answer
I've done what you said, but the anything else vhost is getting requests for – DanielGibbs Nov 18 '11 at 3:36
Are you sure the vhosts match the NameVirtualHost exactly? Please post your config. – Shane Madden Nov 18 '11 at 3:37 I'm trying to redirect anything that is not for to – DanielGibbs Nov 18 '11 at 3:41
Hrm - not 100% sure if this is required (I've never tried without one), but try adding ServerName something.something.something to your 000-default vhost. – Shane Madden Nov 18 '11 at 3:54
Straight from the Apache documentation: If you are using name-based virtual hosts, the ServerName inside a <VirtualHost> section specifies what hostname must appear in the request's Host: header to match this virtual host. – Garrett Nov 18 '11 at 5:09

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.