Forum Moderators: phranque

Message Too Old, No Replies

Have I done this redirect correctly?

301 redirect

         

martini55

12:21 pm on Jul 25, 2006 (gmt 0)

10+ Year Member



Hey, I have just moved my website from www.mysite.com to www.mysite.co.uk. I wanted to do a 301 redirect from the .com to the .co.uk. Have I done it right? In the .htaccess file I have put the following:

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.example.com [NC]
RewriteRule ^(.*)$ http://www.example.co.uk/$1 [L,R=301]

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ http://www.example.co.uk/$1 [L,R=301]

Is this right?

I tried puting this:

RewriteEngine On
RewriteRule ^(.*)$ http://www.newsite.co.uk/$1 [R=301,L]

But it just comes up with 'this page is not redirecting properly'

[edited by: encyclo at 12:38 pm (utc) on July 25, 2006]
[edit reason]
[1][edit reason] examplified [/edit]
[/edit][/1]

jdMorgan

1:05 pm on Jul 25, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The 'Options' and 'RewriteEngine' directives need appear only once at the top.

But you only need one rule to do this, with the 'www' pattern made optional:

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com [NC]
RewriteRule (.*) http://www.example.co.uk/$1 [L,R=301]

I tried puting this:

RewriteEngine On
RewriteRule ^(.*)$ http://www.newsite.co.uk/$1 [R=301,L]

But it just comes up with 'this page is not redirecting properly'


Yes, it would, since there is nothing to discriminate the new doamin from the old. It would redirect from the old to the new, and then continue to redirect from the new to the new, until the server or browser redirection limit is reached. Testing HTTP_HOST before redirecting prevents this.

Jim

martini55

5:08 pm on Jul 25, 2006 (gmt 0)

10+ Year Member



Perfect thanks. So will search engine spiders just see this as one site now? And should I expect the pagerank from the .com to be transferred to the .co.uk?