Canonical issue is a common issue that websites are facing. Due to the this many informative websites are not performing well in search engine results page.
Ranking top in search engine always depends on the quality of information a website is providing, how the site is optimized & the back-links along with the content language and it’s uniqueness.Still any site is not performing well in search engine then there must be some issues like canonical, blacklisted IP etc.
What is canonical issue?
For example if you have the website
http://www.yourwebsite.com
and then the index page can be also accessible by these URLs:
http://www.yourwebsite.com
http://www.yourwebsite.com/index.html
http://www.yourwebsite.com/index.php
http://yourwebsite.com/index
http://yourwebsite.com
In these cases all the pages are same at user end, means the user will found the same page information at each URL. But search engine crawler treats these pages as different pages. So the crawler will treat it like different pages.
Everything the title, meta tags, content etc are same on these pages. So the search engines will consider it as a case of content duplicate and the search engine will consider the site pages as spam and it can de-index your page and affect the search result page in short the Site Ranking decreases.
How to can you solve URL canonical issues ?
We can solve this issue by redirecting all these URLs to a single URL permanently(301 Redirect).
By uploading a .htaccess file we can easily redirect all the URLs.
1.Code to redirect non www domain (http://yourwebsite.com/) to www domain (http://www.yourwebsite.com/) permanently (301):
Options +FollowSymLinks RewriteEngine on RewriteCond %{HTTP_HOST} ^yourwebsite\.com RewriteRule ^(.*)$ http://www.yourwebsite.com/$1 [R=301,L]
2.Code is to redirect index.html to http://www.yourwebsite.com/
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index\.html\ HTTP/ RewriteRule ^(.*)index\.html$ /$1 [R=301,L]
3.Code is to redirect index.php to http://www.yourwebsite.com/
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*folder/index\.php\ HTTP/ RewriteRule ^(.*)folder/index\.php$ /folder/$1 [R=301,L]
After adding these rules in .htaccess file we just need to upload it to the root folder of the website.