简体   繁体   English

htaccess阻止wp-comments-post.php垃圾邮件

[英]Htaccess To Block wp-comments-post.php Spam

I am trying to block spam bots from submitting comments to my customized Wordpress blog. 我试图阻止垃圾邮件机器人向我的自定义Wordpress博客提交评论。 I want to do this via .htaccess but something seems to be wrong with my code because many spam bots are still getting through. 我想通过.htaccess来执行此操作,但是我的代码似乎有问题,因为许多垃圾邮件机器人仍在通过。 Here's my htaccess code. 这是我的htaccess代码。 The trick is that my Wordpress installation is not located at the domain root but in /wordpress/ 诀窍是我的Wordpress安装不是位于域根目录,而是位于/ 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 第一种选择-如果您要将恶意请求重定向到您的wp-comments.php某处,请创建与可疑IP地址匹配的条件

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 第二种选择是拒绝可疑的IP地址访问您网站的任何部分

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 希望这有助于加油

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM