WebmasterSite.net

Redirect entire site

Version: 5.1.34
URL:

PrintPrint


Redirect entire site
jayweb
Forum Regular

Usergroup: Customer
Joined: Nov 27, 2006

Total Topics: 131
Total Posts: 384
quote post #1
Posted 06/16/10 - 11:45 AM:

I need some advice on this because although I could probably do it after a bit of experimenting, it is really important I get it right first time.

I am moving a site from adomain.co.uk to adomain.com

I have decided to start listing businesses outside the UK, so I am changing to .com

How do I do a permenant htaccess 301 redirect so that all of my pages will redirect to the new domain correctly?



Paul
developer
Avatar

Usergroup: Administrator
Joined: Dec 20, 2001
Location: Diamond Springs, California

Total Topics: 65
Total Posts: 7614
quote post #2
Posted 06/16/10 - 1:11 PM:

Each page needs to redirect to the same page on the other domain? This might work, haven't tested:
Options +FollowSymlinks
RewriteEngine on
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.+)\.(.+)
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ http://www.newdomain.com/$1 [L,R=301]
 
Search thread for
Download thread as


Sorry, you don't have permission to post. Log in, or register if you haven't yet.