开发者

Block IP ranges and redirect using htaccess file

Hi I'm trying to block people from a particular country to view my website and I tried this

ErrorDocument 403 http://somewebsite/forbidden.html
<Limit GET HEAD POST>
order allow,deny
deny from 41.66.192.0/18
deny from 41.74.80.0/20
deny from 41.75.48.0/20
deny from 41.76.24.0/21
deny from 41.77.64.0/21
deny from 41.78.40.0/22
deny from 41.78.124.0/22
deny from 41.78.144.0/22
deny from 41.79.84.0/22
deny from 41.93.128.0/17
deny from 41.139.0.0/18
deny from 41.189.128.0/19
deny from 41.190.68.0/22
deny from 41.190.88.0/22
deny from 41.191.96.0/22
deny from 41.191.240.0/21
deny from 41.202.0.0/19
deny from 41.204.32.0/19
deny from 41.210.0.0/18
deny from 41.211.0.0/19
deny from 41.215.160.0/20
deny from 41.218.192.0/18
deny from 41.220.48.0/20
deny from 41.222.232.0/22
deny from 80.87.64.0/19
deny from 192.251.202.0/24
deny from 193.108.23.0/24
deny from 193.108.28.0/24
deny from 193.194.128.0/24
deny from 193.194.160.0/19
deny from 196.1.116.0/23
deny from 196.1.118.0/24
deny from 196.1.137.0/24
deny from 196.3.64.0/24
deny from 196.29.96.0/19
deny from 196.29.224.0/20
deny from 196.43.194.0/24
deny from 196.43.196.0/24
deny from 196.43.206.0/23
deny from 196.开发者_StackOverflow社区44.48.0/20
deny from 196.44.96.0/19
deny from 196.46.80.0/20
deny from 196.201.2.0/24
deny from 196.201.32.0/19
deny from 196.201.160.0/19
deny from 196.216.180.0/22
deny from 196.216.188.0/22
deny from 197.220.160.0/19
deny from 197.221.64.0/19
deny from 197.253.64.0/18
deny from 197.255.64.0/18
deny from 212.85.192.0/19
deny from 212.96.0.0/19
#
allow from all
</Limit>

The issue is that I am having a redirect loop. Based on my research, mod_rewrite would the trick great but I am quite new to htaccess mod_rewrite. Can anyone help?


<IfModule mod_rewrite.c>
 RewriteEngine On
 RewriteCond %{REMOTE_ADDR} ^196\.43\.194\. [OR]
 RewriteCond %{REMOTE_ADDR} ^41\.78\.144\. [OR]
 RewriteCond %{REMOTE_ADDR} ^212\.96\.
 RewriteRule . - [F,L]
</IfModule>

It isn't supposed to work for exact subnets though. If this is the server you administer other solutions like mod_geoip is the way to go.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜