Regarding the comment on your question, you only have one site which is served to your users with the two versions of the site (with www
and without www
).
Therefore, you need to 301 redirect one version to the others (as you wish). For this, you can use a .htaccess file if you use Apache as a web server (at the root of your site).
For exemple, here the code to redirect all www
URLs to no-www
URLs:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} !^example\.com [NC]
RewriteRule (.*) http://example.com/$1 [QSA,R=301,L]
</IfModule>
Or the opposite (no-www
to www
):
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
</IfModule>
example.com
andwww.example.com
? If not, you should 301-redirect one version to the other.