Reduce spam on your WordPress blog by using .htaccess

Simply paste the following lines into your .htaccess file. This file is located at the root of your WordPress install.
Remember to always make a backup of your .htaccess file before editing it so, you’ll be able to restore it if something went wrong.

Don’t forget to replace yourdomainname on line 5 by your real domain name.

<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>

Once you saved your .htaccess file, spam bots will not be able to access your wp-comments-post.php file directly. This will significantly reduce the amount of spam received on your blog.

Thanks to AllGuru.net for the tip!

Looking for WordPress hosting? Try WP Web Host. Prices starts at $5/month and you can try it for free!

Reduce spam on your WordPress blog by using .htaccess

Leave a Reply

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