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 would like to know what I have to add to the apache.conf file to achieve the following:

  1. For all requests for which no Virtualhost is specified, they have to go to one of the Virtualhosts that I do have specified (but I don't want to use ServerAlias, because there are too many domains which I would have to list). And I also don't want to use the ErrorDocument 404 option, because I already use it.

  2. a request on the direct IP of the webserver will do a redirect to an URL on another server (now I use a php redirect, with an index.php in the www root)

share|improve this question
up vote 1 down vote accepted

The first virtual host you specify is the default one used in case no other host alias matches. You could use mod_rewrite to match the requested host to see if it is the IP address in question and use a RewriteRule to send them to your desired destination.

share|improve this answer
Thank you, I did not realize that the first virtual host is the default one used in case no other host alias matches. Furthermore I created one virtualhost with Servername & Serveralias the hostname and ip-adress. All together resulted in what I was looking for. Thanks. – Aug 4 '11 at 18:35

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.