views:

82

answers:

2

Im trying to request the following entire site 301 redirect:

word.something.blah.domain.com --> http://www.word.com

I don't know how to write the 301 redirect rule.

Can someone help out?

A: 

put this into root directory of the subdomain:

Redirect permanent / http://www.word.com
dusoft
+1  A: 

I will assume you are using the same directory to serve files on both domains. In which case, a Redirect clause won't work (infinite redirect loop).

With mod_rewrite, you can check the value of the current HTTP_HOST and take a decision based on that:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^([a-zA-Z0-9]+)\.something\.blah\.domain\.com$ [NC]
RewriteRule ^(.*)$ http://www.%1.com/$1 [R=301,NE,L]
Andrew Moore
This works really great Andrew. Thanks! Everything redirects now except .txt files from the previous site such as robots.txt.
Nevermind cache issue. Works perfectly. Thanks again.