A while back I wrote a short note to myself about the other blogs that had posted information on how to cut down on referrer spam. Since that time, I've noticed that 95% of the remaining referrer spam coming into my system had one thing in common: they were all looking for the file /adserver/campaign.php (which doesn't exist).
I've developed the following Apache mod_rewrite rule that seems to be quite effective, and just in time for the February log changeover:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (adserver/campaign.php) [NC]
RewriteCond %{HTTP_REFERER} !=""
RewriteRule ^(.*) %{HTTP_REFERER} [R=301,L]
In plain English, what this says is that if the file requested contains "adserver/campaign.php", and that file doesn't exist on your server either as a file or a directory, and a referrer is set, redirect back to the referrer. Otherwise, proceed normally.
Trackback URL for this post:
http://www.resonant.org/trackback/419
