How to Solve IP Canonicalization Problem

IP Canonicalization Image

The IP canonicalization problem occurs, when a website’s IP address and website’s URL display the same page, but do not resolve to the same URL.

Let’s consider your domain name is example.com and its IP address is 25.50.50.25 When IP address 25.50.50.25 is visited in web browser as http://25.50.50.25, the web server displays the same page as http://example.com.

From a SEO point of view this would cause a duplicate contents problem.

You can see the following image for more understanding:

Good IP Canonicalization

The solution is to create a 301 redirect, a permanent redirect from your one URL to another. You need to redirect website’s IP to the website domain. To do the redirect, you can edit the .htaccess file found in the root directory by adding the following code:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^25\.50\.50\.25 [nc,or]
RewriteCond %{HTTP_HOST} ^example\.com [nc]
RewriteRule (.*) http://www.example.com/$1 [R=301,L]

For above code, you need to replace the 25\.50\.50\.25 with your website’s IP address and replace example.com with your domain name.