Welcome to WebmasterWorld Guest from 54.145.208.64

Forum Moderators: brotherhood of lan & mack

Message Too Old, No Replies

Canonical problems?

How does this happen?

   
2:27 pm on Sep 22, 2006 (gmt 0)

5+ Year Member



I've been looking into why my site took a steep nosedive in the Google rankings recently (after Sept. 15), and just discovered that I have many pages listed with www at the beginning of the URL, and many more not beginning with www.

How much of a problem is this, how does it happen, and what can I do about it? Please keeping in mind that until a couple of days ago, I never heard of "canonical problems," and am not even really sure what the term means (though I did Google it, and ended up back on another wemasterworld forum, where the discussions were over my head). :-)

Many thanks for any and all enlightenment.

11:14 am on Oct 9, 2006 (gmt 0)

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



Try it both with and without, for a number of test cases, and you'll see...
2:36 pm on Oct 9, 2006 (gmt 0)

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



OK. I think this is the final version. The check for index pages should also force the domain to the www version in the rewrite, and the index check should be both domain insensitive (working for both www and non-www index pages), and should occur before any check for non-www URLs:

RewriteEngine on

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]*/)*index\.html? [NC]
RewriteRule ^(([^/]*/)*)index\.html?$ http://www.domain.com/$1 [R=301,L]

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

First, this forces all index pages, both index.html and index.htm to / for both non-www and www, and forces them all to be on www. The redirect works for index pages both in the root and in any folders, and the 301 redirect preserves the folder name in the redirect.

Secondly, for all pages that are on non-www the other 301 redirect forces the domain to be www. This second directive is never used by index pages as the first directive will have already converted all of them.

This 62 message thread spans 3 pages: 62