Dealing with WordPress Spam Comments – Two Viable Solutions

Ignoring Askami from the conversion which will capture almost all comment spam, you may feel that there is little you can do to stop the wades of WordPress spam comments from being left.

Yes, you could add a captua to the comments box, there are several wordpress plugins that do this, but me being a geek prefer more server based options, here are two of my favourites both with the same effect.


.htaccess Redirects

This is the simpler of the two, I have used this for years for keeping banned players out our community websites, in the example below, I replacing it the site with google.com, but it could readily be any site you want, http://yougotrickrolled.com/ is always a good one, I’ll leave the destination to your own selection.

If your hosting provider (or you have enabled htaccess in your Apache config, on by default), then this is a simple, but effective way of redirecting spammers:

RewriteCond %{REMOTE_ADDR} ^188\.143\.232\.39$
RewriteRule .* http://www.google.com [R,L]

This adds a RewriteCond for the IP address and then using RewriteRule sends them to your chosen destination. Most amusing.

http.conf Edits

This is favoured when working in a development environment to keep a site only to specific IP addresses, but it easily works in reverse to keep out entire subnets. After a unfortunate experience with an Indian development company I needed to block four subnets, this worked wonderfully well.

order deny,allow
deny from
deny from 122.169

This works by selectively denying either specific IP addresses like in the first line or entire subnets.

If working in a development environment and say your IP was ‘’ then you could deny everyone else and allow yourself through using:

order deny,allow
deny from All
allow from


0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *