Reduce spam on your WordPress blog by using .htaccess

Reduce spam on your WordPress blog by using .htaccess

Sick of spammers? Of course, Akismet helps a lot, but your .htaccess file can also help: Today’s recipe is a snippet that prevent spam bots to directly access your wp-comments-post.php file, which is used to post comments on your blog.

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>

3 Comments

  1. Chetaru 9 years ago

    Thanks for sharing this information and resources its really help full for me with the help of this we can improve we design and development .

  2. Chetaru 9 years ago

    Thanks for sharing this information and resources its really help full for me with the help of this we can improve our design and development.
    Web Design Company India

  3. Tina 9 years ago

    Wow I must confess you make some very tencrahnt points.

Leave a reply

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

*