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'm trying to redirect from an old hostname to the new one. So far I've got

RewriteEngine On
RewriteCond %{HTTP_HOST} ^foo$ [NC,OR]
RewriteCond %{HTTP_HOST} ^foo.company.com$ [NC]
RewriteRule ^(.*) http://bar.company.com/$1 [R=301]

but when I go to foo.company.com/dir/page.html I don't get redirected. What am I doing wrong?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Turns out some mysterious incident caused three servers to reboot, including the old foo.company.com, it reverted to its old IP, and was fighting for it with the new server.

Got my rules working and refined them to:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^foo$ [OR]
RewriteCond %{HTTP_HOST} ^foo.company.com$
RewriteRule ^/?(.*)$ http://bar.company.com/$1 [R=301]
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.