Welcome to WebmasterWorld Guest from 54.147.44.13

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Allowing a few countries access, but redirecting all others

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

Preferred Member

10+ Year Member

joined:Nov 26, 2004
posts: 364
votes: 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
1:10 pm on June 7, 2011 (gmt 0)

Senior Member from FR 

WebmasterWorld Senior Member leosghost is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Feb 15, 2004
posts:6717
votes: 230


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.
1:14 pm on June 7, 2011 (gmt 0)

Preferred Member

10+ Year Member

joined:Nov 26, 2004
posts: 364
votes: 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.
1:20 pm on June 7, 2011 (gmt 0)

Senior Member from FR 

WebmasterWorld Senior Member leosghost is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Feb 15, 2004
posts:6717
votes: 230


The only one you will find with the accuracy you want is at maxmind..and is not the free one.
1:20 pm on June 7, 2011 (gmt 0)

Preferred Member

10+ Year Member

joined:Nov 26, 2004
posts: 364
votes: 0


Just a thought, but is there any way of doing this, but redirecting other countries to another page on the same website?
1:22 pm on June 7, 2011 (gmt 0)

Senior Member from FR 

WebmasterWorld Senior Member leosghost is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Feb 15, 2004
posts:6717
votes: 230


Yes..there are various ways ..not all involving htaccess ..
1:56 pm on June 7, 2011 (gmt 0)

Preferred Member

10+ Year Member

joined:Nov 26, 2004
posts: 364
votes: 0


What are the various ways please?
2:05 pm on June 7, 2011 (gmt 0)

Senior Member from FR 

WebmasterWorld Senior Member leosghost is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Feb 15, 2004
posts:6717
votes: 230


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.
2:14 pm on June 7, 2011 (gmt 0)

Preferred Member

10+ Year Member

joined:Nov 26, 2004
posts: 364
votes: 0


Thanks, I was trying for free first, if possible. Which way are you doing yours please? PHP, HTaccess ?
3:52 pm on June 7, 2011 (gmt 0)

Preferred Member

10+ Year Member

joined:Nov 26, 2004
posts: 364
votes: 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
6:23 pm on June 7, 2011 (gmt 0)

Senior Member

WebmasterWorld Senior Member wilderness is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Nov 11, 2001
posts:5408
votes: 2


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]
9:18 am on June 14, 2011 (gmt 0)

Preferred Member

10+ Year Member

joined:Nov 26, 2004
posts: 364
votes: 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.
12:38 pm on June 14, 2011 (gmt 0)

Senior Member

WebmasterWorld Senior Member wilderness is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Nov 11, 2001
posts:5408
votes: 2


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.
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members