[How-To] Disable Comment Posting for No Referrer Requests
Comment Spam is one of the most irritating, time and bandwidth consuming affair on your blog. Yeah, on wordpress you must be using Akismet, but still, it does take up all the commodities mentioned above. However, with a simple hack which goes into your .htaccess file, you can actually deny any requests ( POST preferrably) which don’t a referrer field. Usually this a very generic way of filtering comment spammers when they make a request using their automated tools which don’t require them to come over to your blog/website to make a comment.
Comments on Wordpress are POST actions and therefore in this article, i am going to introduce you to a simple snippet which can help you block any POST requests which don’t have a referrer field. In practise, by checking the referrer, the new page can see where the request came from. Often this is done for logging purposes but one service called whos.amung.us has actually made excellent use of it to show interesting analytics ( read: Whos.amung.us gives you simple yet effective analytics)
The below mentioned hack from WpRecipes explains how you can deny any comment posting where a referrer field is missing. Ensure that you modify line 4 and replace your domain there.
Remember to ALWAYS create a backup when editing the .htaccess file.
RewriteEngine On
RewriteCond %{REQUEST_METHOD} POST
RewriteCond %{REQUEST_URI} .wp-comments-post\.php*
RewriteCond %{HTTP_REFERER} !.*yourblog.com.* [OR]
RewriteCond %{HTTP_USER_AGENT} ^$
RewriteRule (.*) ^http://%{REMOTE_ADDR}/$ [R=301,L]
The above code looks for the referer (The url from where the page has been called) when the wp-comments-post.php file is accessed. If a referer exists, and if it is your blog url, the comment is allowed. Otherwise, the spam bot is redirected and the comment will not be posted.
The other interesting way of stopping spam on your website/blog is by blocking the IP address of the spammer. This can easily be setup using a wordpress plugin called WP-Ban. Read about it at [Wordpress] How do you take care of Spam?
Do stay tuned to Technofriends for more, one of the best ways of doing so is by subscribing to our feeds. You can subscribe to Technofriends feed by clicking here.
Related posts:
- [Wordpress] Comment Reply Via Email is now Open to all
- [How-To] Delete Wordpress Spam Comments Using phpMyAdmin
- [Java] Why (and how) to comment your code
- [Wordpress] How do you take care of Spam?
- [Facebook] Now Reply to Comments by Email
how to send free text to China?
Sandra Dalene VanAlstine – Wanted to introduce myself
Thanks
Sandra Dalene VanAlstine
This site contain more than 3000 tv channels at one place
Hello.
My PC worked not correctly, too much errors. Help me, please to fix buggs on my computer.
My operation system is Windows XP.
Thx,
Unetuanuapaph