GICT knowledge base
Using mod_rewrite to redirect an IP address to a domain name
Published
To redirect an IP address to a domain name on an apache webserver using .htaccess and mod_rewrite the following can be done.
Lets say you have the domain name domain.com on IP address 4.2.2.2 and you do want to redirect the IP address to the domain name if just the IP is accessed (say for SEO purposes). That would be http://4.2.2.2 will rewrite to http://domain.com. In your .htaccess file add
RewriteEngine On
RewriteCond %{HTTP_HOST} ^4\.2\.2\.2
RewriteRule (.*) http://domain.com/$1 [R=301,L]
Using the above rule if http://4.2.2.2/filename is accessed a 301 redirect is created to point to http://domain.com/filename
–
Interserver
http://www.interserver.net
Have we provided you with the highest level of service? Like us on Facebook or write on our wall. www.facebook.com/interserver
Visit our new community forums at http://forum.interserver.net/forum/
Related guides
GDPR Compliance for Websites: A Practical Guide for Developers
This guide breaks down GDPR compliance for websites, helping you create secure, transparent sites where privacy thrives.
MiscellaneousThe Beginner’s Guide to Understanding Object Relational Mapping (ORM)
This article provides a comprehensive overview of Object Relational Mapping (ORM), explaining what it is, how it works, and why it is important in modern software...
Miscellaneous5 Best Online tools to Compress and Optimize your Images
Here is the list of the 5 best Image optimization tools available online. Use these tools to compress your images without losing quality.
MiscellaneousHow to Boot Up Your Server on an OVH Kernel
In this tutorial, we can check how to boot up your server on an OVH Kernel. A kernel is responsible for interfacing the operating system and applications
