Silvers
Silvers

Reputation:

301 redirect .htaccess

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?

Upvotes: 0

Views: 660

Answers (3)

If you are keeping everything else the same - that is, the file names - but simply changing the domain, this code is all you need to put on the OLD DOMAIN htaccess:

RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.newdomain\.co.uk
RewriteRule (.*) http://www.newdomain.co.uk/$1 [R=301,L]

Upvotes: 0

Andrew Moore
Andrew Moore

Reputation: 95474

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]

Upvotes: 1

dusoft
dusoft

Reputation: 11489

put this into root directory of the subdomain:

Redirect permanent / http://www.word.com

Upvotes: 0

Related Questions