Help limit WordPress comment spam with your .htaccess file

Many spambots will visit wp-comments-post.php directly to comment on your WordPress site instead of actually going through a post. You can combat this type of spam by modify the .htaccess file of your WordPress site with the following code:

Example:

RewriteEngine On
RewriteCond %{REQUEST_METHOD} POST
RewriteCond %{REQUEST_URI} .wp-comments-post.php*
RewriteCond %{HTTP_REFERER} !.*mydomain.* [OR]
RewriteCond %{HTTP_USER_AGENT} ^$
RewriteRule (.*) ^http://%{REMOTE_ADDR}/$ [R=301,L]

Note: You will need to replace mydomain with your domain name with no prefix.

Example:

RewriteCond %{HTTP_REFERER} !.*mennosites.ca.* [OR]