psst.. this blog is on hiatus.

Sick of referrer spam

I’m sick of seeing my nice web stats polluted by referrer (referer) spam. Some clown at gb.com decided to go nuts with spamming my site, so via a quick Google to this site, I set up this mod_rewrite rule in my .htaccess file to blow up the spammers.

RewriteEngine On
RewriteCond %{HTTP_REFERER} gb\.com [NC]
RewriteRule \.*$ - [F,L]

UPDATE 1/9/04: ILoveJackDaniels.com has an excellent page on combatting referrer spam.

UPDATE 1/25/04: Fighting spam with .htaccess is an unwinnable battle, but if you’re committed to it, I suggest adding this rule to block .info and .biz domains that contain hyphens:

RewriteCond %{HTTP_REFERER} [a-z]+\-[a-z]+\.(biz|info) [NC]

It’s also a good idea to block domains that go nuts with hyphens in the subdomain and domain, since these are almost always the spawn of spammers. I suppose you could catch a false positive here, but it’s unlikely.

RewriteCond %{HTTP_REFERER} [a-z]+\-[a-z]+\-[-a-z]+\.[-a-z]+\.(com|net|org|biz|info) [NC,OR]
RewriteCond %{HTTP_REFERER} [a-z]+\-[-a-z]+\.[a-z]+\-[-a-z]+\.(com|net|org|biz|info) [NC]

Really, though, you should check out my far more informative proposal to combat referrer spam.

Comments are closed.