Since my journal is of a personal nature – I don't really want it indexed on Google. I had previously posted about a way to "temporarily" remove your site from their index – unfortunately, it DOES time out! I've done this a number of times, and… well… it's BAAACKK.
If you can't beat 'em – pretend you don't exist, and maybe they'll go away.
I've now added code to my blog so that if you get to it from a google search you get a "file not found" page. For those of you wishing to hide from Google – here's how I did it:
At the top of (every) page (obviously – this is done as an include) – BEFORE any <html> tags I have this:
<?
$itsagoogle = 'google.';
$ref = getenv("HTTP_REFERER");
if (($ref) and (strstr($ref, $itsagoogle)) ) {
print('<head><title>File Not Found</title></head><body><H1>File Not Found</h1><p>The requested URL was not found on this server.</p></BODY>');
exit;
}
?>
That's it! Now if you do a search in google, and my site comes up – you'll get that generic "file not found page". I'm all for simple solutions!!!
(Standard disclaimer: This requires that you can run php on your page and server)
update: For those of you who used this code previous to 11:00pm on 5/18 please note I made a slight change so that ANY google referrer would be blocked (ie. the original script didn't work if they came from a www.google.ca search) but now it's fixed…
Update 3/16/03: Ron had a hack elsewhere that would work here if you'd like to add bad more rejected referrers in addition to Google. With his hack, here's how it goes: (this should be one of the first things on your page)
<?
function isBadReferrer($ref)
{
if (
(strstr($ref, "google.")) or
(strstr($ref, "aolsearch.aol.com")) or
(strstr($ref, "search.yahoo.com")) or
(strstr($ref, "search.msn.com")) or
(strstr($ref, "hotbot.com"))
//add more like the above line to add more "rejected" referrals
)
{
return true;
}
else
{
return false;
}
}
$ref = getenv("HTTP_REFERER");
if (($ref) and (isBadReferrer($ref) )) {
print('<head><title>File Not Found</title></head><body><H1>File Not Found</h1><p>The requested URL was not found on this server.</p></BODY>');
exit;
}
?>
Related posts:
- swfobject – flash doesn't load in Firefox Ran into a bizarre problem today using swfobject. A lot...
Related posts brought to you by Yet Another Related Posts Plugin.
scriptygoddess
