How to Create a Canonical URL Creating a Canonical URL
SEO experts recommend that you avoid duplicate content by setting a canonical URL. Canonicalization, www vs. non-www, tells the search engines which URL you would like to use. This helps to avoid duplicate content and upsetting the search engine gods.
Which is Better for SEO?
Neither. It does NOT matter. It's all a matter of preference. Using www or non-www for your website does not effect your rankings. Search engines don't care which one you choose, what IS important is that you DO choose. Once you have made your choice, stick with it. Stick with it throughout your own website content and make sure that all inbound links are using the same format of your domain. This will only give your Canonical URL more strength.
So now that you have made a choice, what do you do about it? Declare it to the world and most importantly, to the search engines! Create a 301 redirect from your non-canonical URL to your chosen canonical URL. This way, search engines will automatically redirect inbound links to your canonical URL, giving it the full credit that it deserves.
How to Create a 301 Redirect
It's very easy, which is why I am including it here on the template site. Follow the directions and you...yes you, can do it yourself! Below are a couple of ways you can create a 301 Redirect, the first is through your web host control panel. The other, you will need FTP access and a program such as IPSwitch or Filezilla (Free).
Create a 301 Redirect Using CPanel
Login to your web hosting administration panel (CPanel)
Find Domains > Redirects

Select the following settings for WWW:
Type: Permanent (301)
http://yourdomain.com
redirect to: http://www.yourdomain.com
www. redirection: Select Do Not Redirect www.
Check the box for Wildcard Redirect

Done and done. Now go check it out! If everything was done correctly you should type your domain name without the www. into your browsers address bar and it will automatically take you to www.yourdomain
If you would prefer to redirect www. to non-www use the following settings:
- Type: Permanent (301)
- http://www.yourdomain.com
- redirect to: http://yourdomain.com
- www. redirection: Select Only redirect with www
- Check the box for Wildcard Redirect
Create a 301 Redirect Using .htaccess
- Download the .htaccess file via FTP
- Open the file in a plain text editor (e.g. Notepad)
- Copy and paste the code below (changing yourdomain.com to your real domain)
- Upload the file via FTP back onto your server*
If you prefer your domain WITH WWW. use the code below:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^yourdomain.com [NC]
RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [R=301,L]
If you prefer your domain WITHOUT WWW. use the code below:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.yourdomain.com [NC]
RewriteRule ^(.*)$ http://yourdomain.com/$1 [R=301,L]
You may want to save the .htaccess file as htaccess.txt, upload it back onto your server then Rename it to .htaccess
Why? Because many operating systems and FTP applications are unable to read or view .htaccess files by default.
As a configuration file, .htaccess is very powerful. Even the slightest syntax error (like a missing space) can result in your content not displaying correctly or at all.
Since .htaccess is a hidden system file, please make sure your FTP client is configured to show hidden files. This is usually an option in the program's preferences/options.
Once you have created the 301 redirect to your preferred Canonical URL, the changes should take effect immediately. Test that the redirection is working properly by entering your URL in the address bar (with or without www, depending on your preferred domain).




