通过重写规则来实现屏蔽ip访问

order allow,deny
deny from xxx.xxx.xx.x
deny from xxx.xx.x.
deny from xxx.xx.x.
deny from xxx.xx.x.
deny from xxx.xx.x.
allow from all

在.htaccess文件里使用上述文件无效的时候可以使用以下代码解决问题手工创建.htaccess文件到站点根目录

RewriteEngine On
#Block ip
RewriteCond %{http:X-Forwarded-For}&%{REMOTE_ADDR} (8.8.4.4|8.8.8.) [NC]
RewriteRule (.*) - [F]

Linux下规则文件.htaccess(手工创建.htaccess文件到站点根目录)

RewriteEngine On
#Block ip
RewriteCond %{http:X-Forwarded-For}&%{REMOTE_ADDR} (8.8.4.4|8.8.8.) [NC]
RewriteRule (.*) - [F]