Page 1 of 1

Prevent sites from redirecting to my site's ip address

Posted: Wed Feb 26, 2014 2:44 pm
by techgal128
I have found three different sites through Google that are exact duplicates of mine. I checked the ip of all of them and it seems they are all pointing to my site's ip address. I was told that I can use an htaccess file to prevent this but I'm not quite sure how to write it. Help?

Re: Prevent sites from redirecting to my site's ip address

Posted: Thu Feb 27, 2014 2:52 pm
by thulsa_doom
Depending on how your site works, this isn't necessarily a bad thing. More traffic, more readers, all that good stuff. That said, the following is one way to nix people who have pointed their domain names at your IP:

Code: Select all

RewriteEngine On
RewriteCond %{SERVER_NAME} !example.com [NC]
RewriteRule ^(.*)$ http://example.com/goaway.html [R,L]
Basically this tests to see if the "server name" environment variable contains "example.com" and inverts the result (so "www.example.com" is a false, "example.com" is false, but "examples.com" if true). If the result it true, it redirects the visitor to http://example.com/goaway.html

Put a little content into a file named "goaway.html" shooing folks off, and you're good to go.

This doesn't actually stop them from pointing at your domain, but it scuttles whatever utility they were getting out of it.

Re: Prevent sites from redirecting to my site's ip address

Posted: Fri Feb 28, 2014 11:41 am
by techgal128
Thank you! I downgraded to virtual hosting to prevent it as a temporary measure. I'll give this a shot.