Become Wordpress Professional - Your Ultimate Wordpress Guide

Wednesday, 20 March 2013

How to Protect Comment Spamming in Wordpress

How to Protect comment spamming in WordPress
In this tutorial you will learn about using the .htaccess file to prevent the type of spam that is No Referrer Spam. No Referrer spam happens when spammers target the WordPress comment script directly without actually busying your website like a regular human being. Preventing this type of spam helps to save ban with other valuable server resources and also help keep your site clean and perfect for your visitors.

Method to Block comment spamming in WordPress

Open your online web host Cpanel account here you see files and directories that are located in WordPress installation directory. To protect against noreferrer spam open your site root .htaccess file after it copy the following code


# BLOCK NO-REFERRER SPAM - Method 1
<IfModule mod_rewrite.c>
 RewriteEngine On
 RewriteCond %{REQUEST_METHOD} POST
 RewriteCond %{HTTP_USER_AGENT} ^$ [OR]
 RewriteCond %{HTTP_REFERER} !.*example.com.* [NC]
 RewriteCond %{REQUEST_URI} /wp\-comments\-post\.php [NC]
 RewriteRule .* - [F,NC,L]
</IfModule>

Copy the entire code and paste it any beneath any existing rule in your root .htaccess file. The only thing you need to edit is the highlighted example.com to Your website URL. Make the change and all set. Next is the save the file. Once that done you need return to your website and check everything is working proper or not. Load pages, posts and other area of your website to confirm the changes are correct or not.

Verifying the code to protect comment spamming 

When everything is great and the code is actually working and doing what is supposed to do to block no referrer spam. To confirm the changes GO to

www.botsvsbrowsers.com/Simulateuseragent.asp

and in the URL field write the complete URL of your comment directory file. By default it is

www.YourSiteName.com/WordPress/wp-comments-post.php

and in Request field chose Post because here is the spammer doing.


Click the Go button to make it so and if everything is OK then you see the Forbidden Error 



As expected the post request give 403 Forbidden error which is perfect for spammers that are trying to directly spam using your comment post script. At this point your .htaccess code is working great. Spammers that are trying to hit directly your WordPress based comment site comment script will now either be blocked. 

This method increase your site security and also speed up your WordPress site because there are no more reaching your comment directory that is better responsive and user friendly based web sign for your visitors.

1 comment:

  1. Is there any way to get the plugin to include the featured image? psd to html

    ReplyDelete

Please Avoid Spamming. Comments will be moderated before they are published.