Forum Moderators: open

Message Too Old, No Replies

Blocking users

         

Tezus

2:03 pm on May 1, 2003 (gmt 0)



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

korkus2000

2:08 pm on May 1, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to WebmasterWorld,

You probably want to detect the user information through a server side language. Then serve up your page without the link. I don't know how effective your detection will be though. What server side language does your host have?

Hobgoblin

8:36 am on May 6, 2003 (gmt 0)

10+ Year Member



If your server is Apache, you can deny users from a country using .htaccess , this will work best if your download link is in a subdirectory - then place the .htaccess file in that subdir as so:

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]

Sinner_G

8:42 am on May 6, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Blocking all .se will probably won't be enough, since many people in any given country have .com's. I can't think of any way of blocking users working for someamericancompany.com in the Sweden subsidiary...

Hobgoblin

8:47 am on May 6, 2003 (gmt 0)

10+ Year Member



I concur-

Unless there are any major legal ramifications on your part (and I can't possibly see why), I would just place a disclaimer by your download link that the following is illegal in X countries and that you hold no respobsibility whether they heed the advidce ot not and get busted :)

rayvd

4:39 pm on May 6, 2003 (gmt 0)

10+ Year Member



It would be fairly trivial for a user to circumvent that filter by using an IP address with no reverse lookup. With Apache, we use the RewriteEngine stuff in the server config file to redirect requests from a matching IP address(es) to a page notifying them they cannot access the page. For example:

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.