最近本站DeveWork.com 老是被来自142.4.108.109这个ip的垃圾评论骚扰,看来之前的《代码实现 WordPress 反垃圾评论功能》用处还是有限的。于是想到了用Apache 的.htaccess 屏蔽这个垃圾评论ip。
![](/sites/default/files/get_image/2014/08/15/7ecd7057ca491c605c8007b6e53534fa.jpg)
方法如下:
在空间的根目录的.htaccess加入以下代码:
1、如果要屏蔽某一特定IP可以使用:
2、如果想要屏蔽多个IP地址,只需多加几个deny from 即可
3、如果需要屏蔽整个IP段,可以使用
4、如果只想屏蔽IP段中的一小部分IP,则可使用
完工,以后来自被屏蔽ip的访问只会显示如图的403页面:
Forbidden
You don’t have permission to access / on this server.
Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.