blog-banner

Apache Redirect IP Requests to Domain Name

  • Apache
  • SEO

At times Apache is configured to serve a site through IP address as well. For a production site with proper domain and things this could affect SEO due to content duplication.

A quick fix for the same could be to have a redirect rule in .htaccess file which comes by default in most web applications.

The below rewrite will do the trick,

RewriteCond %{HTTP_HOST} ^74\.127\.228\.193$
RewriteRule ^(.*)$ http://google.com/$1 [L,R=301]

The first line checks if the request is posted through IP address while the second line redirects to the domain name on the match.