Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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