0

尝试阻止 IP 时,我有一个包含以下代码的 htaccess 文件:

DirectoryIndex index.php index.html

ErrorDocument 404 /errors.php

Order Allow,Deny
Deny from 188.143.232.
Allow from all

浏览 www.example.com 时阻止我自己的 IP 有效,但不会阻止其他任何内容(如 www.example.com/index.php 或 www.example.com/home,...)。htaccess 与 index.php(httpdocs 文件夹)位于同一目录中。

我怎样才能让它工作?

4

1 回答 1

2

您还可以使用基于 mod-rewrite 的 ip-blocking 来阻止不需要的 ip(s) :

RewriteEngine on

#--if client ip==188.143.232
RewriteCond %{REMOTE_ADDR} ^188\.143\.232
#--forbid the request
RewriteRule ^ - [F,L]
于 2016-03-14T10:09:29.257 回答