Combat Spam Comments With .htaccess

I’ve already tried of spam comments. Then I googled a way to combat it. By disabling Direct Access to wp-comments-post.php with .htaccess , it may prevent some autobots sending spam comments to my blog.

Here is the code:

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

(Credit: Cats Who Code)

Hope this can also help you guys prevent spam comments.

Join the Conversation

2 Comments

Leave a comment

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