Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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\.)?wrongsite1.com$     [NC]
    RewriteRule ^(.*)$       http://correctsite1.com/$1 [R=301,L]

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

</IfModule>
</VirtualHost>

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: http://correctsite1.com/http://correctsite2.com

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

1 Answer 1

$ cat /etc/httpd/conf.d/_default.conf 
<VirtualHost _default_:80>
        Redirect / http://YOUR-URL-GOES.HERE
</VirtualHost>
$
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

 
discard

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.