如何使用.htaccess阻止IP访问

时间:2015-04-19 22:04:34

标签: .htaccess ip

我需要通过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

请帮忙

2 个答案:

答案 0 :(得分:1)

尝试不使用;

#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

答案 1 :(得分:-1)

xlhost com inc使用firefox版本27。

将此代码放入htaccess:

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

Source webmaster.net