Last Update September 8, 2019: We improved the overall article.
I want to talk a little bit about canonicalization, www vs. non-www, redirects, duplicate URLs, 302 “hijacking,” etc.
What is a canonical URL? Do you have to use such a weird word, anyway?
Sorry that it’s a strange word; that’s what we call it around Google.
Canonicalization is the process of picking the best URL when there are several choices, and it usually refers to home pages.
For example, most people would consider these the same URLs:
www.example.com
example.com/
www.example.com/index.html
example.com/home.php
But technically all of these URLs are different. A web server could return completely different content for all the URLs above.
When Google “canonicalizes” a URL, we try to pick the URL that seems like the best representative from that set.
How to Setup
Simple Open your .htacces
file vai any ftp client application and add the flowing code:
# BEGIN RewriteCond %{HTTPS} !=on RewriteCond %{HTTP_HOST} !^www..+$ [NC] RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L] # END
Note: This will add “www.” even if there is already a subdomain.