Prevent Spam Comments from bots in WordPress

Prevent Spam Comments from bots in WordPress

Preventing Spam Comments from bots in wordpress, this snippet goes inside the .htaccess file in your server.

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