In Apache HTTP , Nginx and SEO Last updated:
Share on:
Cloudways offers managed cloud hosting for any size business to host a website or complex web applications.

If you are hosting your website on Cloud or dedicated server then, you will be given dedicated IP by the hosting provider.

This means your website is accessible through domain and IP, both of which could cause duplicate content if the 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 problems in Nginx and Apache webserver.

Test IP Canonicalization

You can either access your IP address manually to check if it’s getting redirected or use the following online tools to test.

Fix IP Canonical issue in Nginx

  • Login to your Nginx server.
  • Take a backup of nginx.conf file
  • Create a new server block like below
server { 
server_name 45.55.20.xx; 
return 301 http://yourdomain.com; 
}
  • Very obvious, you have to change the 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 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.

Share on:
  • Chandan Kumar
    Author
    Chandan Kumar is a seasoned technology enthusiast and entrepreneur passionate about empowering businesses and individuals globally. As the founder of Geekflare, a leading technology publication, Chandan has spearheaded the development…

Thanks to our Sponsors

More great readings on Apache HTTP

Power Your Business

Some of the tools and services to help your business grow.
  • The text-to-speech tool that uses AI to generate realistic human-like voices.

    Try Murf AI
  • Web scraping, residential proxy, proxy manager, web unlocker, search engine crawler, and all you need to collect web data.

    Try Brightdata
  • Monday.com is an all-in-one work OS to help you manage projects, tasks, work, sales, CRM, operations, workflows, and more.

    Try Monday
  • Intruder is an online vulnerability scanner that finds cyber security weaknesses in your infrastructure, to avoid costly data breaches.

    Try Intruder