digitalFAQ.com Forum

digitalFAQ.com Forum (https://www.digitalfaq.com/forum/)
-   Website and Server Troubleshooting (https://www.digitalfaq.com/forum/web-tech/)
-   -   Block WordPress Spam: How to deny comments to non-referrer traffic (https://www.digitalfaq.com/forum/web-tech/2328-block-wordpress-spam.html)

kpmedia 07-25-2010 10:06 PM

Block WordPress Spam: How to deny comments to non-referrer traffic
 
You can edit your .htaccess** to prevent spammers posting on your blog.

Most spammers uses bots that lack a referrer. The referrer is the page a person was reading when he/she clicked to leave a comment. Bots didn't click on a link, and therefore lack a proper referrer.

This code will look for the a referrer, and deny comments if the wp-comments-post.php file without directly coming from your blog.

Just change yourblog.com with the URL of your site, using the following code:

Code:

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]

And that's it. :)


** Note that Apache (usually Linux) comes with .htaccess abilities, and not Windows IIS servers. If you're using Windows, then you'll need a third-party application that lets you use .htaccess.


All times are GMT -5. The time now is 04:16 PM

Site design, images and content © 2002-2024 The Digital FAQ, www.digitalFAQ.com
Forum Software by vBulletin · Copyright © 2024 Jelsoft Enterprises Ltd.