{title}


Code RSS Feed

Code

Country specific content

TOPICS:
  • Apache

Recently I was asked to make a site visible to visitors of only a certain country. There’s several ways to do this, the easiest being to modify the .htaccess file for your site.  I found a site which allows you to generate a list of IP ranges by country. From there, it is a simple matter of modifying or creating an .htaccess file to place in your site’s root. To deny access from a certain IP range:

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

and to include from only a certain IP range:

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