如何使用 .htaccess 阻止 IP 访问

How to block access by IP using .htaccess

我需要通过 IP 地址阻止访问我的站点,但由于某些原因,当我使用以下内容时出现错误 500。

这是我正在尝试使用的:

#Deny Access to Adsense SPAM
Order Deny,Allow
deny from 209.51.197.0/24; # XLHOST IP
deny from 209.190.121.32/27; #XLHOST IP
deny from 209.190.0.0/17; # XLHOST IP
deny from 173.45.64.0/18; # XLHOST IP
deny from 64.79.64.0/19; # XLHOST IP
deny from 64.79.89.0/19; # XLHOST IP
deny from 64.79.85.0/19; # XLHOST IP
allow from all

请帮忙

不用;

试试
#Deny Access to Adsense SPAM
Order Deny,Allow
deny from 209.51.197.0/24 # XLHOST IP
deny from 209.190.121.32/27 #XLHOST IP
deny from 209.190.0.0/17 # XLHOST IP
deny from 173.45.64.0/18 # XLHOST IP
deny from 64.79.64.0/19 # XLHOST IP
deny from 64.79.89.0/19 # XLHOST IP
deny from 64.79.85.0/19 # XLHOST IP
allow from all

xlhost com inc 使用 firefox 版本 27。

将此代码放入您的 htaccess 中:

RewriteCond %{HTTP_USER_AGENT} Firefox/27\.0 [NC]
RewriteRule .* - [F,L] 

Source webmaster.net