Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to allow access only within country

Tags:

.htaccess

I found this web site to generate a .htaccess to block an access from certain country.

The problem with this is that I want to allow access only within Norway. If I use this service, the list will be very long since I have to list all the country IP addresses.

Is there any way to allow access within country, my case is Norway?

like image 805
shin Avatar asked Aug 19 '09 12:08

shin


1 Answers

Change all occurences of 'deny' to allow, and all occurrences of 'allow' to deny. Then move the 'deny from all' condition at the end to the beginning of the list.

eg.

<Limit GET HEAD POST>
order allow,deny
deny from 41.205.32.0/19
deny from .... 
allow from all
</LIMIT>

becomes

<Limit GET HEAD POST>
order deny,allow
deny from all
allow from 41.205.32.0/19
allow from ....
</LIMIT>

There's some good tutorials about .htaccess.

like image 156
gbjbaanb Avatar answered Nov 15 '22 06:11

gbjbaanb