Blog

Block spam and save bandwidth on your blog

Here’s a quick and easy way to kill two (proverbial) birds with one stone.

I might not have the same amount of activity on my blog as other sites but the site is still a frequent target for spam bots.  I alleviated much of my frustration by installing Akismet (and it does a truly fantastic job).  Still, I monitored regular visits and spam posts (well, attempts anyway as Akismet caught them) from the same IP addresses.

What I did was create a .htaccess file on my web site with the following entry:

deny from xxx.xxx.xxx.xxx

Where the X’s are the IP address of the problematic spammer, for example:

deny from 169.254.0.188

This solution works great because WordPress doesn’t have to handle anything, the web server simply forbids access whenever an attempt to visit the site is even made.  This saves server resources and bandwidth.

It should be mentioned that this solution isn’t perfectly ideal.  Many (most, really) Internet IP addresses are dynamically assigned–given to a computer for only a short period of time before being reassigned to another computer.  Eventually these HT Access entries could block a potentially legitimate visitor.  It worked for me because I noticed the addresses of the spammers had not changed for quite some time.  At some point in the future I’ll comment out those lines in the file and see if the heavy spamming resumes.

So this can work to quickly stop an annoying spam bot that regularly plagues your site, but it’s not a permanent anti-spam solution.  For that I strongly recommend Akismet.

Leave a Comment