View Single Post
  #13 (permalink)  
Old 01-18-2008, 12:10 AM
Webnauts's Avatar
Webnauts Webnauts is offline
WebProWorld 1,000+ Club
WebProWorld MVP
 
Join Date: Aug 2003
Location: Worldwide
Posts: 8,132
Webnauts RepRank 8Webnauts RepRank 8Webnauts RepRank 8Webnauts RepRank 8Webnauts RepRank 8Webnauts RepRank 8Webnauts RepRank 8Webnauts RepRank 8Webnauts RepRank 8
Default Re: Canonicalization Prevention Guide

Allow me to add mine here too:

########## Require the www to avoid cannonicalization issues ###
RewriteCond %{HTTP_HOST} ^yoursite.com [NC]
RewriteRule ^(.*)$ http://www.yoursite.com/$1 [L,R=301]

########## Require to add trailing slash if not present to avoid cannonicalization issues ###
RewriteCond %{HTTP_HOST} !^www\.yoursite\.com [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteRule ^/(.*) http://www.yoursite.com/$1 [L,R]

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

########## Redirect https to http ###
RewriteCond %{SERVER_PORT} ^443$
RewriteRule (.*) http://www.yoursite.com/$1 [R=301,L]

If you have https pages indexed because you have done a mistake, you can create an additional robots.txt calling it for example robots-secure.txt disallowing the indexed files and this in your .htaccess file:

########## To get rid of https files and cannonicalization issues ###
#RewriteCond %{SERVER_PORT} ^443$
#RewriteRule ^robots.txt$ robots-secure.txt
__________________
"Being an expert isn't telling other people what you know. It's understanding what questions to ask, and flexibly applying your knowledge to the specific situation at hand. Being an expert means providing sensible, highly contextual direction." Jeff Atwood
SEO Workers - Search Engine Optimization Consulting Company | SEO Analysis Tool | Webnauts Net SEO
Reply With Quote