Forum Moderators: open
Is it possible to block visitors from a certain country from using a download link?
The laws in my country does not allow casinos or marketing of casinos with real money play. That´s why i have to find a way to block the swedish visitors from using the download link.
Can i add a script to the links?
Thanks in advance, Terése
www.yoursite.com/download/.htaccess
Here is what goes in the .htaccess file:
order allow,deny
deny from .se
allow from all You can deny access from users of any country, even block US government and military - if one was so inclined :P
And as korkus stated, you can also do this with an SSI language like PHP.
.htaccess only works on Apache servers. Also, this will not work if the user's IP doesn't resolve to a name such as blah.isp.se
[edited by: Hobgoblin at 8:42 am (utc) on May 6, 2003]
RewriteEngine on
RewriteLogLevel 4
RewriteLog "/var/log/httpd/rewrite_log"
RewriteCond %{REMOTE_ADDR} ^200\.6[4567]\..+$ [OR]
RewriteCond %{REMOTE_ADDR} ^67\.32\.53\.67$
RewriteRule ^(/.+) /unauthorized.html [L]
Basically I'm blocking a rather large subnet in Mexico here, and an IP address somewhere in Virginia. All matching IP's are redirected to the unauthorized.html file. You could easily use this in combination with host-based matching to really keep someone out of your site :)
[httpd.apache.org...] is a good reference for these rewriting rules.