homepage Welcome to WebmasterWorld Guest from 54.242.204.141
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
301 redirect site A to site B
kellyman




msg:4479889
 1:14 pm on Jul 29, 2012 (gmt 0)

Hi Guys posted here a few months back and wanted some best practice feedback

10 weeks ago i changed my domain name, we implemented a straight forward 301 along with canonical fixes

Everything went really well server responses show 301 and the intended page on the new site shows all ok 200

Now 10 weeks on I still have no traffic, this is a 17k page site with the old url's going to their own individual pages.

I just took a subscription in SEOMOZ and found that its showing me nearly 4k 301 when i look at the original page and the redirected page they are identical so not sure if its a reporting glitch or my 301 is chaining some how as there are no 301's on the new site, there are only the canonical elements in the php script

But the question i want to ask is from the old site my developer is adamant that he canonicalises those URLs in the old site before they are sent to the new site even though the new site has the same 301 in place in case anyone does point to the non www (he fixes all the canonical elements and upper-case URLs along with the removal of trailing slash) this is on both the new and old

I would have thought we just did the basic 301 from site a to site b and then on the new site add any canonical element.

10 weeks is a long time without any traffic i am 99% sure theres a problem however everything looks perfect

 

rainborick




msg:4479912
 4:05 pm on Jul 29, 2012 (gmt 0)

This really belongs in the Google News category, but until we get there...

Ordinarily, if the site is configured to do 301 redirects for all requests using the old domain name pointing to the same URI/file name with the new domain name, you'd expect the transition to be nearly complete after just a few weeks. A minor traffic drop is to be expected during this period, so a persistent major drop means something's wrong: either the redirects are set up improperly, the rel=canonical tags are set improperly, the changes have induced a major ranking issue, or you've coincidentally run into a change in Google's ranking methods.

The first thing to do is to check your site's status in Google's index. Does the site: operator in Google show most or all of your site's pages indexed using the new domain name and does it show a dramatically reduced number of pages indexed under the old domain name? What does Bing show for these same searches?

kellyman




msg:4479913
 4:30 pm on Jul 29, 2012 (gmt 0)

Hi rainborick

Thansk for taking the time to reply

Not sure why this would be in Google until i can prove its just Google not playing ball

But to answer your question all the new pages were index within 48 hours it looked really straightforward and went without a hitch, a site:mysite shows all the pages, if i do that on my old site it shows some of the old site but around 200 of the 17k left.

I just thought it was Google going slow as in Bing its fine and pages kind of where they were before.

The transition is complete but no rankings, it like Google is not giving the credit to the site.

But it was those 301s showing up in SEOmoz crawl thats baffling me as im not tracking the old site just the new site and the new site dont have any 301's in place

I did think about being caught in a algorithmic problem but i would still rank for some things, even if i copy text from my home page, my site dont show up but it does for its name,

But going back to the initial setup on the old site i would think that it just needs the single line to say old site moved to new, but my developer says that is not the way it should be and has, set the rules of the php script to convert to lower case , fix canonical's and remove the trailing slash, that too is implemented on the new server so why have it twice

g1smd




msg:4479919
 6:02 pm on Jul 29, 2012 (gmt 0)

from the old site my developer is adamant that he canonicalises those URLs in the old site before they are sent to the new site even though the new site has the same 301 in place in case anyone does point to the non www (he fixes all the canonical elements and upper-case URLs along with the removal of trailing slash) this is on both the new and old

Do NOT fix on the old site using a redirect WITHIN the old site and then redirect again to the new site.

Redirect to the canonical URL on the new site with a single step fix from whatever URL was originally requested (old site anything, or new site non-canonical).

kellyman




msg:4479922
 6:20 pm on Jul 29, 2012 (gmt 0)

Thanks g1smd

as i thought , although seems working im sure theres more to go wrong, ill get that changed first thing tomorrow

I think just this will be fine on the old
RedirectMatch 301 ^(.*)$ [mysite.com...]

And canonical fix on the new ..

g1smd




msg:4479957
 10:41 pm on Jul 29, 2012 (gmt 0)

No.

Imagine you redirect old site index.html to new site index .html and then redirect new site index.html to new site root, that is an unwanted multiple-step redirection chain.

Redirect index.html on old site to new site root and index.html on new site to new site root, where "site root" is
www.example.com/ with a trailing slash.

Fix issues as you redirect, always in a single step.

kellyman




msg:4479967
 11:47 pm on Jul 29, 2012 (gmt 0)

Ok Think i get what you are saying, but will the above assume they are on the smae server as they are not, they are on different servers and different I.P's. and my URL's have always had the trailing slash removed in the past

I know this has been discussed 100's of times but searching for examples there are always something s a little different.

Can you point me to a topic that you have discussed with an exact example, I know you guys post on the basis that you want us to learn, however I will not ever get to see the htaccess side and have to rely on my developer to get it right, and he is very good, but i think like me we dont actually have experience with this, and as you can see we have been 9 weeks in limbo and i know there's an issue.

Basically i think this is now correct,

RewriteRule (.*) [newsite.com...] [R=301,L]:

g1smd




msg:4479971
 12:11 am on Jul 30, 2012 (gmt 0)

You need a copy of the code, in order to review it.


Let's say your old server (example.net) had this old code (27, 28, 29):

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

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

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


Some people would be tempted to just add this code (30) on the end of those three rules or in place of those three rules:

# 30 - Redirect to new site
RewriteRule (.*) http://www.example.com/$1 [R=301,L]


to redirect to the new server (example.com).

That would be a mistake as it would introduce a multiple step redirection chain.


You'd need to instead alter the above rules (27, 28, 29) on the old server (example.net) to directly point all of these requests to the correct URL on the new server (example.com).

# 27 - Redirect index requests to new site, correcting path within the redirect
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index(\.(php|html?))?
RewriteRule ^(([^/]+/)*)index(\.(php|html?))?$ http://www.example.com/$1? [R=301,L]

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

# 30 - Redirect all other requests to www on new site
RewriteRule (.*) http://www.example.com/$1 [R=301,L]



as well as add these rules (31, 32, 33) on the new site (example.com):

# 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]

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved