Solution for Canonicalization Problems by using Htaccess
- Article
- Comment
Solution for Canonicalization Problems by using Htaccess is one of the important work in SEO. You need to add two lines of code into your site .htaccess file. Which will take care of the 301 Re-directions. Also the problem is one of a headache issue in SEO. So making a url strong is better and gets more optimized results. From your Page visit will get huge change after the Redirection.
There are two Canonicalization is available.
- IP Canonicalization
- URL Canonicalization
1. IP Canonicalization
Lets write the code to get better results,
RewriteCond %{HTTP_HOST} ^146\.255\.44\.1 RewriteRule ^(.*)$ https://www.kvcodes.com/$1 [L,R=301
The above one is my site redirection with my ip address, Likewise you can change your site IP address and domain to create your re-directions,
2. URL Canonicalization :
There is another Canonicalization is URL . There is some difference in the following urls, as per the SEO view. But all the urls bring you to the same page. But these are all technically different.
www.kvcodes.com
kvcodes.com
kvcodes.com/index.php
www.kvcodes.com/index.php
So, all these urls make the Search engines get confused to drive peoples to a url . So you need to provide a single url and make your site visitors try to visit some other urls, redirect them to the same. so Search engine can also bring more traffic to you.
The following rewrite rule helps you to perform redirection.
RewriteCond %{HTTP_HOST} ^kvcodes\.com$ [NC] RewriteRule ^(.*)$ https://www.kvcodes.com/$1 [L,R=301]
Here I changed my site url from non-www to www. You can make any one as permanent url.
RewriteCond %{HTTP_HOST} ^www\.kvcodes\.com$ [NC] RewriteRule ^(.*)$ https://kvcodes.com/$1 [L,R=301]
This also possible. But keep your url with WWW. so it looks good and fine for the multiple sub domain sites.
if you have any doubts and queries ask below.