I am using ISAPI-Rewrite on IIS7.
How can we combine [NC] and [OR] in a RewriteCond ? [NC,OR] ?
What is the simple way to match domains with and without "www." ?
Here is a draft :
RewriteCond %{HTTP_HOST} ^old-one.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www.old-one.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^old-two.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www.old-two.com$ [NC]
RewriteRule ^(.*)$ http://www.new-website.com/$1 [QSA,L,R=301]
Yes, [NC,OR] is the way of combining those two flags.
To combine multiple similar conditions into one, try this one:
RewriteCond %{HTTP_HOST} ^(old-one\.com|www\.old-one\.com|old-two\.com|www\.old-two\.com)$ [NC]
RewriteRule .* http://www.new-website.com%{REQUEST_URI} [L,R=301]
P.S. Since you are on IIS 7, why not use their native rewriting engine (URL Rewrite module) -- yes, it has different syntax (not .Apache's .htaccess, but standard web.config XML file) but does work fine (no performance issues here on my servers).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With