The most common use for this is for telling your web server to only display pages either with the “www.” or without it, but not both. This is typically done by editing a special file named “.htaccess” located in your web servers “root” or top most folder. If you are not VERY comfortable making changes to your server configuration, or your site is hosted on a windows server (most are not), you may need to contact your hosting company to get this set up for you.
If you want your site to only be viewed without the “www.“ then you should add this code to the bottom of your .htaccess file:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^mywebsite.com [NC]
RewriteRule ^(.*)$ https://mydomain.com/$1 [L,R=301]
If you want to force your site to use the “www.”, then you should add this code to the bottom of your .htaccess file:
RewriteEngine on
rewritecond %{http_host} ^domain.com [nc]
rewriterule ^(.*)$ https://www.domain.com/$1 [r=301,nc]
I feel it’s important to caution you again – while the code used to do redirects is rather simple, even a small error can have significant consequences for your site. Use EXTREME caution.
As far as SEO is concerned, neither way is better than the other, just be consistent. However, shorter domains are generally easier to use on various social sites.
Canonicalization is also useful at the individual file or post level. If you use WordPress, or practically any Content Management System (CMS) to run your site there is a very good chance you are creating multiple paths you’re your content, also called “duplicate content”, without even realizing it. Can visitors get to your pages through archives, categories or tags? If yes, you are probably have duplicate content. This should be an easy fix though. Google and the other engines adopted the use of a special META tag (Sorry – more of them) called the canonical tag. It’s a way for you to tell the engines which path it should consider the “correct” path. In WordPress there are plugins like the All in One SEO Pack that will create this for your automagically. If you are creating code by hand then you just need to add the following to the HEAD section of your pages:
<link rel="canonical" href="https://www.yourdoman.com/path-to-your-post/" />
I know this post ranked high on the geek-o-meter, but hopefully no one’s head exploded. Duplicate content is a serious issue, but thankfully it’s one that is easily avoided on your own sites and now you know how to do it, or at least now you know you have to tell your host to fix it.
It’s been a few weeks since we started this series – hopefully you are finding them helpful and are seeing some positive effects in your rankings.
