1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

.htaccess file is a simple ASCII file created with any text editor such as NotePad. It is a file extension, so you can NOT make it look like “example.htaccess” or “sitename.htaccess”. The file is named .htaccess

.htaccess works within the folder it resides and all sub folders as long as there is no other .htaccess file in any of these sub folders. There can be multiply number of such files on your server, each of them defining different parameters on your server.

How to solve Google canonical issue with .htaccess file?

For Google search engine website addresses with www and without ww are different URl addressess and therefore it may give different PageRanks to those websites. For instance “example.com” and “www.example.com” are different URL’s and they may possess PageRank of 3 and 4. That is very bad situation from SEO point of view as you should always try to keep as much link juice on your site as possible.

There is a fix to that problem. You need to insert the following code into your .htaccess file and put it in the same folder as your homepage:

RewriteEngine On

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

Exchange domain with your domain name and that it. All your traffic will be permanently redirected from a non-www version of your website to a www version of your website. That way you will keep all your PageRank on your website and the canonical issue will not arise on your website.

If you prefer to direct all traffic to your non-www version of your website use the following code in your .htaccess file:

RewriteEngine On

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

Sphere: Related Content