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

I am doing 301 redirects for old sites to a single site, rather then having to add the same RewriteRule more then once, is there a way to say write it once? that way i just need to add the rewriteCond once?

My current code

RewriteEngine on 

RewriteCond %{HTTP_HOST} ^Oldsite.local [NC]
RewriteRule ^(.*)$ newSite.local%2 [L,R=301]

RewriteCond %{HTTP_HOST} ^Oldsite2.local [NC]
RewriteRule ^(.*)$ newSite.local%2 [L,R=301]

I tried : RewriteEngine on

RewriteCond %{HTTP_HOST} ^Oldsite.local [NC]   
RewriteCond %{HTTP_HOST} ^Oldsite2.local [NC]
RewriteRule ^(.*)$ newSite.local%2 [L,R=301]

but that doesnt seem to work

share|improve this question

2 Answers 2

up vote 1 down vote accepted

try this:

RewriteCond %{HTTP_HOST} ^Oldsite.local [NC, OR]   
RewriteCond %{HTTP_HOST} ^Oldsite2.local [NC]
RewriteRule ^(.*)$ newSite.local%2 [L,R=301]

this will change the implicit logical and of RewriteCond to a logical or.

share|improve this answer

RewriteCond's are normally 'AND's, however you can change them to 'OR's byt adding the OR option to the end.

More info

share|improve this answer

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.