c# .net Adsense ADO.NET Linq Viruses/security asp.net MVC JQuery Angular-js Node-js SEO Java C++ SQL API Networking vb.net .Net Css JavaScript Generics c#.Net entity framework HTML Website host Website Construction Guide HTTP tutorial W3C tutorial Web Services JSON Psychology Ionic framework Angular ReactJS Python Computer Android
SEO

How to set preffered domain in webmaster tools (www or non-www)?

| | SEO-tips

If not, setting redirect www to non www or vice-versa will create duplicity of site. Because google thinks the www and non-www version as different pages.

How to avoid duplicity of site using Google webmaster tool?

To avoid that, we should set the preferred domain (www or non-www).It tells the google webmaster which domain to crawl and index. Otherwise, our site gets penalized in search engines. We should ensure only one URL (www or non-www) is accessible and the other one is redirected.

Sometimes, we may lose valuable search engine traffic due to incorrect configuration. When any search engines come to the site for crawling, it checks for any redirect setup. If not able to follow any redirects, it will think the site has no contents.

If we have specifieddomain as http://www.example.com and we find links to our site is formatted as http://example.com,We will be treated as a http://www.example.com.

Setup you site using google webmaster tool:

Step 1: First, you need to submit your website to google webmaster tool and verify the ownership of your domain with www and without www. Once your ownership was verified, login to your website domain dashboard under the google webmaster tool.

Click on the gear icon is at the top right corner of and then click on the site settings.

here, you can set up your preferred domain. You need to select the www or non-www version of your domain. 

Once you set your preferred domain. You have to set up 301 redirection, if you have a WordPress blog, don’t worry about it, By default WordPress will do it.For other users don’t forget to change.

Step 2: Open your file manager of your domain and create a file and name it as .htaccess.Copy and paste the following code and edit your domain name and save the file.

Setup guide: youtube link

If you have preferred www version, use this:

RewriteEngine On
RewriteCond %{HTTP_HOST} !^(.*)\.YourDomainName\.com$ [NC]
RewriteRule ^(.*)$ http://www.YourDomainName.com/$1 [R=301,L]

If you have preferred non-www version, use this: 

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.YourDomainName.com$ [NC]
RewriteRule ^(.*)$ http://YourDomainName.com/$1 [R=301,L]