In the last year I’ve had people pointing unwanted domain names at my own website content. For example, let’s say I have a web site called http://www.foo.com that uses the name server reallycool.nameserver.com. If I wanted to be a pain in the butt I could point another domain (say http://www.annoyingwebsite.com) at the same content by using a custom DNS A record or a 301 redirect. It’s a pretty simple matter to work out the nameservers and IP of a site by using a tool like this.
The problem with someone doing this to your website is that search engines (like Google) see this second website as a duplicate of your own website. Now, in theory this shouldn’t be a problem because Google should determine that your website was the first listed and pretty much ignore the duplicate site. In theory anyway, but the paranoid part of me says having a copy of your website is a Bad ThingTM. Another problem is that this spurious second site will show up in search listings and also in your website referrer logs. It’s an annoying, and potentially damaging issue.
I tried a few different things to stop this from happening including messing about with .htaccess files but ended up just adding the following to the top of my global header file (which happens to be php).
// //Redirect people hijacking site // if ($_SERVER['HTTP_HOST']!='www.foo.com' && $_SERVER['HTTP_HOST']!='foo.com' && $_SERVER['HTTP_HOST']!='localhost') { Header( "HTTP/1.1 301 Moved Permanently" ); Header( "Location: http://www.google.com" ); }
Note that I’ve got the localhost entry in there to allow for debugging of my websites on my local PC.