使用 htaccess 屏蔽 ip
Blocking ip with htaccess
当我尝试阻止 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 文件夹)相同的目录中。
我怎样才能让它工作?
您还可以使用 mod-rewrite based ip-blocking 来阻止不需要的 ip:
RewriteEngine on
#--if client ip==188.143.232
RewriteCond %{REMOTE_ADDR} ^188\.143\.232
#--forbid the request
RewriteRule ^ - [F,L]
当我尝试阻止 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 文件夹)相同的目录中。
我怎样才能让它工作?
您还可以使用 mod-rewrite based ip-blocking 来阻止不需要的 ip:
RewriteEngine on
#--if client ip==188.143.232
RewriteCond %{REMOTE_ADDR} ^188\.143\.232
#--forbid the request
RewriteRule ^ - [F,L]