Page is a not externally linkable
- Code, Content, and Presentation
-- Apache Web Server
---- 301 redirect best practice


kellyman - 1:12 pm on Sep 6, 2012 (gmt 0)


Hi Guys Implemented a 301 a few months ago (14 weeks to be precise), i have rankings that have dived and not recovered, The original 301 was implemnted by PHP but a few weeks ago i have asked my developer to change this to htaccess which now 50% is done via the old site attempting to do the new site once we confirmed all is best practice

Scenario is

www.example.net was renamed to www.example.com

Both sites sit on different servers along with different I.P's

the new sites 301 is currently handled by php and although we get all the correct headers and such i believe there to be an issue as rankings are still 80% down, this php handles the canonicals and removes the forward slash pretty simple

As i mentioned we are going to implement a htaccess version on both servers

On the old we are going to add the below which is a simple redirect

RewriteEngine on
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]

we were advised to add the below, but we got an internal 500 server error however the single line code works just fine, however there must be a reason for the below and is it best practice...

RewriteEngine On
RewriteCond %{HTTP_HOST} ^example.net$ [OR]
RewriteCond %{HTTP_HOST} ^www.example.net$
RewriteRule (.*)$ http://www.example.com/$1 [R=301,L]


On the new server which is currently being handle by PHP I have sought help already a month or 2 ago but wanted to check that what i was doing was correct and no unwanted chaining being forced, so not implemented yet it will be in the next few days once i get my head around what's exactly needed

On the new server were going to add this which should deal with Canonicals, removal of upper case urls along with, removal of the forward slash

# 31 - Redirect index requests on new server
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index(\.(php|html?))?
RewriteRule ^(([^/]+/)*)index(\.(php|html?))?$ http://www.example.com/$1? [R=301,L]

# 32 - Redirect .php requests to extensionless URL
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(([^/]+/)*[^/.]+)\.php
RewriteRule ^(([^/]+/)*[^/.]+)\.php$ http://www.example.com/$1? [R=301,L]

# 33 - Redirect non-canonical requests to www
RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]

would the above be best practice when doing a website name chnage

Thank you


Thread source:: http://www.webmasterworld.com/apache/4491893.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com