Knowledgebase: Shared Web Hosting
My Site is indexed twice in search engines as "domain.com" and "www.domain.com"
Posted by Richard Moran on 07 October 2013 12:32 PM

If your website is visible both under the domain name and www.domain name, search engines may index your website separately under both URLs.

Using webmaster tools, you can set a "preferred domain" for your site, basically telling the search engine to index either with or without the WWW.

https://support.google.com/webmasters/answer/44231?hl=en

Additionally you can also set up a "301" or "permanent" redirection to redirect traffic from your non-preferred domain, to the preferred, so that visitors (and other search engines) use only you preferred domain.

The best method to set up the redirection is using your websites .htaccess file. Simply insert the following code into the .htaccess file.


(Amend for correct domain name)
---------------------------------------------------------------------
RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain\.com
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=permanent,L]

---------------------------------------------------------------------

 

If you do not already have a .htaccess file, you can create one very simply using notepad. Copy & pasted the code above into a text file, amend with correct domain name and save locally as htaccess.txt. Open the file manager in your control panel, navigate to your websites root directory (where your website "index" file resides), upload the text file and then rename it to .htaccess.

IMPORTANT: For security, permissions on the .htaccess file must be set to read only or "r--r--r--" using the file manager

 

(2 vote(s))
This article was helpful
This article was not helpful