How to redirect website domain name as www to non-www or non-www to www. If it’s hurt Google SEO.
Please provide a simple way to do this.
Thanks.
Non-www domains are not hurt your website SEO. Because the world’s most famous news blog Mashable is running under the non-www domain. http://mashable.com. But Google takes www and non-www domain as a different domain. But it’s not important for SEO. If you feel www is not suitable or compatible with your website or blog change non-www to www.
If you want to change your Preferred domain open your website hosting folder.
open .htaccess file.
add the following line to change domain: www to non-www
<IfModule mod_rewrite.c> RewriteCond %{HTTP_HOST} ^www.example.com$ [NC] RewriteRule ^(.*)$ http://example.com/$1 [R=301,L] </IfModule>
add the following line to change domain: non – www to www
<IfModule mod_rewrite.c> RewriteCond %{HTTP_HOST} ^example.com$ [NC] RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L] </IfModule>
Note: remove example and .com instead of your domain name.
Please refer to Google guide for Preferred domain.
Changing www or non-www domain name can affect Social sharing ( Google Plus, Facebook likes, Twitter tweets, etc)?
Yes, it affects Google plus sharing and Twitter tweets. But it doesn’t affect Facebook like or recommendations.
If you are using nginx, then use this code to redirect
non-www to www
server { listen 80; server_name www.example.org example.org; if ($http_host = example.org) { rewrite (.*) http://www.example.org$1; } ... }
Read this document to find more details about nginx rewrite rules.
Will the redirect work if let’s say I did not add the CNAME record to DNS? I have already chosen my preferred domain in google per your guild above.
You don’t need to add any CNAME records.