PDA

View Full Version : Redirecting old domain to new domain with htaccess


BatCountry
06-10-2009, 03:26 AM
I'm moving my old site to a new domain, problem is that I have a lot of people linking to articles on my old site. So I want those urls to be automatically redirected using the new domain url.

I want the PR to pass through so I heard I should do a 301 permanent redirect.

The best way to do this is to use htaccess but I can't figure out what the exact command should be to sniff the domain and redirect so that it uses the new domain.

Both sites are using the same hosting, so I want the old domain to simply redirect using the new domain:
http://www.oldomain.com/path/file.php

Should 301 redirect to
http://www.newdomain.com/path/file.php

Can anyone help me out here on this one.

schleppel
06-10-2009, 11:35 PM
Try
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{HTTP_HOST} ^(www\.)?OLD\.com$ [NC]
RewriteRule .* http://www.NEW.com%{REQUEST_URI} [R=301,L]