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 10.10.10.10, accessing to http://10.10.10.10 will redirect you to http://yourdomain.com

 

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 (.*) http://yourdomain.com/$1 [R=301,L]

 

Using this rule if http://10.10.10.10 is accessed then a 301 redirect is created to point to http://yourdomain.com



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