FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » How to redirect user based on user country?
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
How to redirect user based on user country? [message #175630] Fri, 14 October 2011 03:00 Go to next message
justaguy is currently offline  justaguy
Messages: 16
Registered: December 2010
Karma: 0
Junior Member
Hi,

I wonder how we can accomplish this task?
Say, a user from India lands at http://www.knowledgenotebook.com/download.html
(actually it would be http://www.knowledgenotebook.com/download.php )
I'd like to direct this visitor to http://bla.bla.bla.bla.in/download.html

And if the user is from China
it would be redirected to http://bla.bla.bla.bla.cn/download.html
so and so forth.

This approach would be more elegant if easily doable. If so how?

Though another approach is also doable, messy.
Download mirror site in India
Download mirror site in China
....

Thanks.
Re: How to redirect user based on user country? [message #175633 is a reply to message #175630] Fri, 14 October 2011 07:31 Go to previous messageGo to next message
Arno Welzel is currently offline  Arno Welzel
Messages: 317
Registered: October 2011
Karma: 0
Senior Member
justaguy, 2011-10-14 05:00:

> Hi,
>
> I wonder how we can accomplish this task?
> Say, a user from India lands at http://www.knowledgenotebook.com/download.html
> (actually it would be http://www.knowledgenotebook.com/download.php )
> I'd like to direct this visitor to http://bla.bla.bla.bla.in/download.html
>
> And if the user is from China
> it would be redirected to http://bla.bla.bla.bla.cn/download.html
> so and so forth.
>
> This approach would be more elegant if easily doable. If so how?

You can use a GeoIP database (e.g. <http://www.maxmind.com/app/php>)
which gives you a rough location based on the IP address of the client.
This doesn't make sence of course without servers actually located in
different countries.


--
Arno Welzel
http://arnowelzel.de
http://de-rec-fahrrad.de
Re: How to redirect user based on user country? [message #175637 is a reply to message #175633] Fri, 14 October 2011 09:42 Go to previous messageGo to next message
justaguy is currently offline  justaguy
Messages: 16
Registered: December 2010
Karma: 0
Junior Member
On Oct 14, 3:31 am, Arno Welzel <use...@arnowelzel.de> wrote:
> justaguy, 2011-10-14 05:00:
>
>> Hi,
>
>> I wonder how we can accomplish this task?
>> Say, a user from India lands athttp://www.knowledgenotebook.com/download.html
>> (actually it would behttp://www.knowledgenotebook.com/download.php)
>> I'd like to direct this visitor tohttp://bla.bla.bla.bla.in/download.html
>
>> And if the user is from China
>> it would be redirected tohttp://bla.bla.bla.bla.cn/download.html
>> so and so forth.
>
>> This approach would be more elegant if easily doable.  If so how?
>
> You can use a GeoIP database (e.g. <http://www.maxmind.com/app/php>)
> which gives you a rough location based on the IP address of the client.
> This doesn't make sence of course without servers actually located in
> different countries.
>
> --
> Arno Welzelhttp://arnowelzel.dehttp://de-rec-fahrrad.de

All right, thanks, so, it's quite involved.
Re: How to redirect user based on user country? [message #175638 is a reply to message #175630] Fri, 14 October 2011 09:53 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 10/13/2011 11:00 PM, justaguy wrote:
> Hi,
>
> I wonder how we can accomplish this task?
> Say, a user from India lands at http://www.knowledgenotebook.com/download.html
> (actually it would be http://www.knowledgenotebook.com/download.php )
> I'd like to direct this visitor to http://bla.bla.bla.bla.in/download.html
>
> And if the user is from China
> it would be redirected to http://bla.bla.bla.bla.cn/download.html
> so and so forth.
>
> This approach would be more elegant if easily doable. If so how?
>
> Though another approach is also doable, messy.
> Download mirror site in India
> Download mirror site in China
> ...
>
> Thanks.
>
>

You can't do it reliably. You can only go by the user's ip address
using one of the geoip databases around.

But these databases have limited accuracy. They depend on the user's ip
address being in the same country as the user (which may or may not be
correct, especially for dial-up users and those using a proxy).
Additionally, they depend on an ISP not allocating ip addresses across
multiple countries.

Additionally, just because a server is in the same country doesn't mean
it's necessarily the best server to use. There are many reasons a
server in another country would be better.

A better way is to display a list of servers and let the user choose.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: How to redirect user based on user country? [message #175641 is a reply to message #175637] Fri, 14 October 2011 11:18 Go to previous messageGo to next message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
justaguy wrote:
> On Oct 14, 3:31 am, Arno Welzel <use...@arnowelzel.de> wrote:
>> justaguy, 2011-10-14 05:00:
>>
>>> Hi,
>>> I wonder how we can accomplish this task?
>>> Say, a user from India lands athttp://www.knowledgenotebook.com/download.html
>>> (actually it would behttp://www.knowledgenotebook.com/download.php)
>>> I'd like to direct this visitor tohttp://bla.bla.bla.bla.in/download.html
>>> And if the user is from China
>>> it would be redirected tohttp://bla.bla.bla.bla.cn/download.html
>>> so and so forth.
>>> This approach would be more elegant if easily doable. If so how?
>> You can use a GeoIP database (e.g. <http://www.maxmind.com/app/php>)
>> which gives you a rough location based on the IP address of the client.
>> This doesn't make sence of course without servers actually located in
>> different countries.
>>
>> --
>> Arno Welzelhttp://arnowelzel.dehttp://de-rec-fahrrad.de
>
> All right, thanks, so, it's quite involved.

Yes.

You need to develop and probably manually maintain a database of IP
address blocks versus country.
Re: How to redirect user based on user country? [message #175645 is a reply to message #175637] Fri, 14 October 2011 17:09 Go to previous messageGo to next message
houghi is currently offline  houghi
Messages: 45
Registered: September 2011
Karma: 0
Member
justaguy wrote:
>> You can use a GeoIP database (e.g. <http://www.maxmind.com/app/php>)
>> which gives you a rough location based on the IP address of the client.
>> This doesn't make sence of course without servers actually located in
>> different countries.
>
> All right, thanks, so, it's quite involved.

As long as you have recent updates for the data, it is not that bad.
However I personally detest it and rather be able to decide for myself.

As this is for download (and not so much the site itself) this is about
speed for the downloader, I assume. Even then I rather be able to select
my own mirror. I know I can have higher speeds from another country then
from my own on some servers.

So at least give the option to select during e.g. 15 seconds (or
whatever you think will be apropriate)

The example on the URL above is all that there is to it, but obviously
you must first decide which ones go where and where do the other ones go
to.

houghi
--
Dr. Walter Gibbs: Won't that be grand? Computers and the programs
will start thinking and the people will stop.
-- Tron (1982)
Re: How to redirect user based on user country? [message #175648 is a reply to message #175645] Sat, 15 October 2011 15:25 Go to previous message
justaguy is currently offline  justaguy
Messages: 16
Registered: December 2010
Karma: 0
Junior Member
On Oct 14, 1:09 pm, houghi <hou...@houghi.org.invalid> wrote:
> justaguy wrote:
>>> You can use a GeoIP database (e.g. <http://www.maxmind.com/app/php>)
>>> which gives you a rough location based on the IP address of the client..
>>> This doesn't make sence of course without servers actually located in
>>> different countries.
>
>> All right, thanks, so, it's quite involved.
>
> As long as you have recent updates for the data, it is not that bad.
> However I personally detest it and rather be able to decide for myself.
>
> As this is for download (and not so much the site itself) this is about
> speed for the downloader, I assume. Even then I rather be able to select
> my own mirror. I know I can have higher speeds from another country then
> from my own on some servers.
>
> So at least give the option to select during e.g. 15 seconds (or
> whatever you think will be apropriate)
>
> The example on the URL above is all that there is to it, but obviously
> you must first decide which ones go where and where do the other ones go
> to.
>
> houghi
> --
> Dr. Walter Gibbs: Won't that be grand? Computers and the programs
> will start thinking and the people will stop.
>                                                   --  Tron (1982)

Yeah, I agree listing mirror site may be a better choice. Thanks.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: including CSS & JS on only pages that need that CSS & JS
Next Topic: Can I stop sending content-length header?
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Fri Nov 22 14:51:14 GMT 2024

Total time taken to generate the page: 0.02057 seconds