rel="canonical"
solution is frequently used between two pages with same content (not for an entire website). Explanations here.
Base tag is different and used to specify default URL for all relative URLs in the page.
However, keep available two versions of your website (www
and no-www
versions) can be hasardous because it generates duplicate content. And Google doesn't like duplicate content, that's why it's good seo pratice to redirect www to no-www or the opposite.
If you use Apache HTTP Server as web server, you can create .htaccess file in root of your domain (if it doesn't already exist) and add these lines to redirect (301 redirect) www
to no-www
:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} !^example\.com [NC]
RewriteRule (.*) http://example.com/$1 [QSA,R=301,L]
</IfModule>
Of course, you replace example.com by your website URL.
You also can choose the opposite (redirect from no-www
to www
) if you prefer. No matter for seo if you choose one or other solution.
What is important is to implement 301 redirect solution unlike rel="canonical"
solution to do this.