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 am setting up a Catchall as an Apache vhost. The idea is to have this vhost process all requests that have not been fulfilled by earlier definitions, and then conditionally redirect them to another URL. Here's what I have so far:

<VirtualHost *:80>
ServerName default
ServerAlias *

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{HTTP_HOST}    (www\.)?$     [NC]
    RewriteRule ^(.*)$$1 [R=301,L]

    RewriteCond %{HTTP_HOST}    (www\.)?$     [NC]
    RewriteRule ^(.*)$$1     [R=301,L]


It seems like the processing of rules does not stop, after the first rule is processed, even though it is set as last. Meaning, from wrongsite1, I end up with a URL of:

What am I doing wrong?

Edit: in the final version, there will be only 2 correct site URLs, with several RewriteConds, using [OR].

share|improve this question
What's apachectl -S look like? I suspect there's more than one redirect happening, since it most certainly doesn't make sense for both of those rules to trigger at the same time. Can you turn on RewriteLog /path/to/log and RewriteLogLevel 9? – Shane Madden Aug 9 '12 at 5:46
$ cat /etc/httpd/conf.d/_default.conf 
<VirtualHost _default_:80>
        Redirect / http://YOUR-URL-GOES.HERE
share|improve this answer
Thank you, however, this will not conditionally redirect to another URL based on the originally requested URL. – djdy Aug 8 '12 at 19:47
right, I actually read it carefully and yes, that's not exactly what you're looking for... sorry – alexus Aug 8 '12 at 19:49

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.