Block WordPress spam comment with .htaccess

If you have self hosted WordPress and always got lots of spam comment, you may actually blocked them through your .htaccess file.

The source code as below was get from AllGuru.Net,

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

Open the .htaccess file and place the code as above then you shall be able to filter the spam automatically.