homepage Welcome to WebmasterWorld Guest from 54.161.175.231
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / WebmasterWorld / New To Web Development
Forum Library, Charter, Moderators: brotherhood of lan & mack

New To Web Development Forum

This 62 message thread spans 3 pages: < < 62 ( 1 2 [3]     
Canonical problems?
How does this happen?
miki99




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

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.

 

g1smd




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

Try it both with and without, for a number of test cases, and you'll see...

g1smd




msg:3114123
 2:36 pm on Oct 9, 2006 (gmt 0)

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 ( 1 2 [3]
Global Options:
 top home search open messages active posts  
 

Home / Forums Index / WebmasterWorld / New To Web Development
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