1

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].

1
  • 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? Aug 9, 2012 at 5:46

1 Answer 1

0
$ cat /etc/httpd/conf.d/_default.conf 
<VirtualHost _default_:80>
        Redirect / http://YOUR-URL-GOES.HERE
</VirtualHost>
$
2
  • Thank you, however, this will not conditionally redirect to another URL based on the originally requested URL.
    – djdy
    Aug 8, 2012 at 19:47
  • right, I actually read it carefully and yes, that's not exactly what you're looking for... sorry
    – alexus
    Aug 8, 2012 at 19:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .