I am trying to block spam bots from submitting comments to my customized Wordpress blog. I want to do this via .htaccess but something seems to be wrong with my code because many spam bots are still getting through. Here's my htaccess code. The trick is that my Wordpress installation is not located at the domain root but in /wordpress/
RewriteEngine On
RewriteCond %{REQUEST_METHOD} POST
RewriteCond %{REQUEST_URI} /wordpress/wp-comments-post.php
RewriteCond %{HTTP_REFERER} !.*mydomain.org.* [OR]
RewriteCond %{HTTP_USER_AGENT} ^$
RewriteRule (.*) http://%{REMOTE_ADDR}/$ [R=301,L]
Thanks! :)
To resolve your spam issue you have to identify where are the spam comments coming from and what to do with the requests
first option - if you want to redirect the malicious requests to your wp-comments.php somewhere create a condition matching the suspicious ip address
RewriteEngine On
RewriteCond %{REMOTE_ADDR} ^123\.45\.67\.89$
RewriteCond %{REMOTE_ADDR} ^123\.45\.67\.90$
RewriteCond %{REMOTE_ADDR} ^123\.45\.67\.100$
RewriteRule wp-comments-post\.php http://putyourredirecturlhere [R=301,L]
second option is deny suspicious ip addresses to access any part of your site
order allow,deny
deny from 198.112.3.4 #Ip address you want to block
deny from 198.112.3.42 #Ip address you want to block
allow from all
Hope this helps cheers
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.