If you are hosting your website on VPS like DigitalOcean or dedicated server then, you will be given dedicated IP by hosting provider.
This means your website is accessible through domain and IP both which could cause duplicate content if search engine indexes both URL and IP.
Duplicate content is not good for SEO, and this is something you should fix it immediately if found.
In this article, I will talk about how to test and fix IP canonical problem in Nginx and Apache web server.
Test IP Canonicalization
You can either access your IP address manually to check if it’s getting redirected or use following online tools to test.
Fix IP Canonical problem in Nginx
- Login to your Nginx server.
- Take a backup of nginx.conf file
- Create new server block like below
server { server_name 45.55.20.xx; return 301 http://yourdomain.com; }
- Very obvious, you have to change IP and domain name with yours.
- Restart Nginx, and you are all good now.
Fix IP Canonical issue in Apache
- Login to your Apache server
- Take a backup of httpd.conf file
- Ensure mod_rewrite is enabled
LoadModule rewrite_module modules/mod_rewrite.so
- Add following Rewrite rule
RewriteEngine on RewriteCond %{HTTP_HOST} ^128.199.100.xxx RewriteRule (.*) http://yourdomain.com/$1 [R=301,L]
Make sure you to change 128.199.100.xxx to your actual IP.
This is one of the hundreds of SEO metrics, and if interested in more you should analyze your website for SEO.
Thanks, Chandan!
Your rewrite for Apache solved my problem :))
Great Bob.
I am facing a wiered issue .The url is mapped to domain.However after website is launched its works well for sometime and after say 40-50 seconds .The domain name is replaced by ip in the link and nothing works
Hello Puja,
Sounds like there is some reference which is holding the IP address.
I’m having problems getting this to work properly. I think it’s because I have multiple website on the same server using the same ip address. Could that be the case?
Sounds like some conflicts. You need to check the logs for better clue.
It works fine!!
Thanks
Great!
Hi,
In my server have 20 site and I was put in htacess file those command but not working
RewriteEngine on
RewriteCond %{HTTP_HOST} ^128.199.100.xxx
RewriteRule (.*) http://yourdomain.com/$1 [R=301,L]
Can you tell me How can I fix that ?
Thanks
Hello Dan,
Just to check if you replace 128.199.100.xxx with your IP and yourdomain.come with your domain?
I’d also recommend this tool for bunch of useful SEO checks, including canonical URL and IP check.
https://www.pageportrait.com
Thanks for the link Sanjeev.
My server manager is telling me that this can only be done if we get an ssl certificate, is this true?
Hello Jonathan,
I don’t think so.
i am doing exactly as you said but i am still having problem please help me…
Our website ip is not directing to the domain – what do we do?