Redirecting an IP address to a domain using mod_rewrite

Sometimes you need to redirect an ip address to a domain for SEO purposes or for many other reasons, for example an account with a dedicated ip to the domain name. This can be performed easily using mod_rewrite.


For example if your ip is, accessing to will redirect you to


Simply add the following lines in the .htaccess file in your public_html directory changing the domain and the ip number with your information:


RewriteEngine On
RewriteCond %{HTTP_HOST} ^10\.10\.10\.10
RewriteRule (.*)$1 [R=301,L]


Using this rule if is accessed then a 301 redirect is created to point to

  • 4 Users Found This Useful
Was this answer helpful?
Related Articles
Copyright © 2020 PlusPlusHosting.Net. All Rights Reserved. is an authorized reseller of goods and services provided by PlusPlusHosting.Net.