homepage Welcome to WebmasterWorld Guest from 54.197.130.16
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
Allowing a few countries access, but redirecting all others
Dexie




msg:4322880
 1:06 pm on Jun 7, 2011 (gmt 0)

Seem to be getting really stuck on this and could do with some help from some of you experts if you could please? Is there any way of allowing just a few countries access, (USA, Mexico and Canada), and redirecting all other countries to another website please?

Must be 100% accurate, or at least 95%. Minimal load on the server. Free would be nice, but could pay 10-15 usd a month, if it was worth it.

The hosts have given me the info below, in case it's of any help.

The following Perl modules are installed on the server:
Geo::IP 1.39
Geo::IPfree 1.110450
Geography::Countries 2009041301
Installed Net_GeoIP PEAR module.

The file path to the module is :
/opt/geoip/share/GeoIP/GeoIP.dat

Any help much appreciated.

Dexie

 

Leosghost




msg:4322881
 1:10 pm on Jun 7, 2011 (gmt 0)

Using your favorite SE ..search for "geo ip redirect" or "geo ip block" or "geo ip ban" ..and there have been loads of threads here in the past on this ..some relatively recent.

Dexie




msg:4322886
 1:14 pm on Jun 7, 2011 (gmt 0)

Many thanks Leosghost - have done that, but wondered if any of the members here had any hands on experience of any way of doing this.

Leosghost




msg:4322888
 1:20 pm on Jun 7, 2011 (gmt 0)

The only one you will find with the accuracy you want is at maxmind..and is not the free one.

Dexie




msg:4322889
 1:20 pm on Jun 7, 2011 (gmt 0)

Just a thought, but is there any way of doing this, but redirecting other countries to another page on the same website?

Leosghost




msg:4322890
 1:22 pm on Jun 7, 2011 (gmt 0)

Yes..there are various ways ..not all involving htaccess ..

Dexie




msg:4322908
 1:56 pm on Jun 7, 2011 (gmt 0)

What are the various ways please?

Leosghost




msg:4322915
 2:05 pm on Jun 7, 2011 (gmt 0)

If you go to the site I mentioned above you will see various scripts ready made for perl, php, javascript etc.

I'm not linking to the page as it is a commercial site and TOS here restricts that.

Personally I use a custom made system because I require it to do more ( and more accurately ) than what is available ..even there.

Dexie




msg:4322924
 2:14 pm on Jun 7, 2011 (gmt 0)

Thanks, I was trying for free first, if possible. Which way are you doing yours please? PHP, HTaccess ?

Dexie




msg:4322992
 3:52 pm on Jun 7, 2011 (gmt 0)

Really trying to solve this. Just tried :

GeoIPEnable On
GeoIPDBFile /opt/geoip/share/GeoIP/GeoIP.dat
RewriteEngine On
#
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^(US|KR|CN|BR)$
RewriteRule ^(.*)$ http://www.google.com/ [R,L]


But, getting a 500 internal server error?

Anyone see anyhting wrong with that code please?

Dexie

wilderness




msg:4323075
 6:23 pm on Jun 7, 2011 (gmt 0)

Seem to be getting really stuck on this and could do with some help from some of you experts if you could please? Is there any way of allowing just a few countries access, (USA, Mexico and Canada), and redirecting all other countries to another website please?


see "You want Class A's [webmasterworld.com]

Dexie




msg:4325821
 9:18 am on Jun 14, 2011 (gmt 0)

Thanks wilderness, have been all through that thread and can't seem to find anything to help in this particular scenario? Also, if it's relevant, I'm on a shared server.

wilderness




msg:4325886
 12:38 pm on Jun 14, 2011 (gmt 0)

either create "deny from"'s for each range or "SetEnvIf Remote_Addr" or "RewriteCond %{REMOTE_ADDR}".

The Class A's I provided will exclude the majority of non- US and Canada IP's.

FWIW, I've used shared hosting since 1999.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved