I have a server which is hosting just a single site and because of this, I intend to redirect all traffic from domains which isn't mine to my domain. For example, if a random person decides for some reason to point their domain to my server, when my server gets the request it redirects to my domain. I have tried various rules in teh .htaccess then going to the IP address to test this but each time I try, it stays on the IP address and doesn't redirect to the domain. Because of this, I decided to start working on just getting it to redirect from the IP to the domain. This is what my .htaccess file currently looks like:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^1\.2\.3\.4
RewriteRule (.*) http://domain.com/$1 [R=301,L]
I have checked through my httpd.conf file and ensured that .htaccess is enabled and that the FollowSymLinks option is enabled (which is why it is not in the .htaccess file) but the redirect still isn't working. I've had a look online and I can't see anything wrong with what I have in my .htaccess file. Could someone give me some pointers on what I need to do or change?
You've probably already worked it out but the IP and domain in the above is not my IP or domain...