How to do IP/URL Canonicalization via .htaceess? Open


What is IP and URL  Canonicalization and why it is important for SEO?

It is quite important to understand Canonicalization. Probably the term is very difficult to pronounce, but it is one of the most important terms in the world of SEO. Canonicalization refers to how a website can use different URLs and/or IP's for the same piece of content (usually the entire web page). For example; every website resolve to a particular IP address of the hosting machine.

“Canonicalization is the process of picking the best URL when there are several choices, and it usually refers to home pages. For example, most people would consider these the same URLs:

But technically all of these URLs are different. A web server could return completely different content for all the URLs above. When Google “canonicalizes” a URL, we try to pick the URL that seems like the best representative from that set.

This behaviour is not search-engine friendly, because the spiders are unsure as which URL is the correct one (If I put it right, which page is a Canonical one among the set of pages with same contents). The search engines don’t like duplicate contents and so URL and to a much lesser extent, IP canonicalization is very important in SEO point of view.

Here’s what Google says about Canonical Page:

A canonical page is the preferred version of a set of pages with highly similar content.

There are 2 types of Canonicalization the most common URL and the other IP, let's take our domain as an example

  1. URL and get redirected to
  2. IP gets redirected to also. (do not do this if you're on a shared IP)

How to configure IP canonicalization in Apache Web server?

The problems with IP Canonicalization can be fixed using the mod_rewrite module and .htaccess. If your website is running on an Apache web server, then you can copy the below lines and paste into the appropriate place in the  .htaccess file located in website’s root directory.

IP Canonicalization has more to do with server-side configuration – although, we can sort this out with a 301 redirect.

IP Canonicalization -- BEGIN
RewriteCond %{HTTP_HOST} ^212\.38\.189\.64
RewriteRule (.*)$1 [R=301,L]
##### IP Canonicalization -- END

*There is no guarantee that IP canonicalization will improve a site's search engine ranking.

Remove the www prefix and redirect to https

To ensure that all URLs of a given domain present without the www prefix, open the domain’s root .htaccess file and add the following chunk of code:

IP Canonicalization -- BEGIN
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^cfts\.co$ [NC]
RewriteRule ^(.*)$$1 [R=301,L]
##### IP Canonicalization -- END

Some control panels like ours will just allow you to make the URL or Domain redirects without having to mess with systems files directly.

For strong SEO, IP Canonicalization you should use 301 redirects and become sure that the IP does not get indexed.

This tells Google, Bing, Yahoo! and all other Search engine crawlers that the current page should be treated as though it were a copy of the URL and that all of the links & contents should technically flow back to said URL and don’t mark the URL page content as a duplicate.

Posted 2 years agoby peter
#1012067 viewsEdited 1 year ago

Please login to post an answer

Mon - Fri: 09:00-17:30 EAT
Weekends: Closed

Public Holidays: Closed

Uganda: +256-(0)392-733784
Uganda: +256-(0)414-533784
Rwanda: +250-(0)786-304817


Ours is a rich history providing holistic ICT support services; by designing, developing, implementing reliable and effective solutions, over the years we’ve learnt a thing or two about helping our customers getting IT right, the first time.

East Africa (Uganda, Rwanda, Kenya, Tanzania, Sudan) and DRC