Status
Not open for further replies.

Byron

New Member
Hi Guys,

I did this years ago and now forget how to do it again :( does anyone have any code for automatically and seemlessly redirecting visitors based on their IP.

Basically what I am trying to do:

If an Irish IP visitor, site goes to http://www.domain.com

If a UK IP visitor, site goes to http://www.domain.com/uk/

... and I know there are exceptions to this working, but a general one which will catch 99% of users.

Scripting on site is simple enough PHP / HTML on Linux server with Cpanel (yes I am learning the other hosts options too :p)

Thanks In Advance,
B
 

php.allstar

New Member
Hi Byron,

Try this, its an apache module you'll need control of apache configuration though so it won't work on shared hosts.

Also not sure about the seo implications...is this deemed as cloaking?
 

Byron

New Member
Thanks for that,

Hmm anything for a shared host? - I remember vaguely using javascript although I may be wrong. I don't know if it would be cloaking, as the content would be different on the redirected page, and also the url wouldn't be rewritten at all. - Just a redirect based on IP.

Thanks,
B
 

mneylon

Administrator
Staff member
You can use maxmind or one of the other services / solutions - I think there was a thread discussing it a while back
Javascript isn't a good solution
 

Byron

New Member
Hi blacknight,

Gonna take a look around, but thanks for the tips, yea found some nasty hack I used years ago, but a database backed system seems best
 

mneylon

Administrator
Staff member
From what I remember we implemented something along these lines ..

php include that grabbed the user's ip.. do a lookup against a data source of IPs (geoip obviously) .. based on the result send the user to a particular page

On one site we were doing it simply to stop people from outside a subset of countries accessing an order form ..
 

mneylon

Administrator
Staff member
As long as the data is relatively fresh you should be ok ..

Now here's an interesting problem for you .. how do you get that to work with IPv6? :)
 

Byron

New Member
A month old, so I would say it will be fine... god I'm gonna cry, how long is the lifetime of IPv4 now :p and how would I make it compatible for IPv6... you really should have a website with lots of Google Adsense for all this!
 

mneylon

Administrator
Staff member
A month old, so I would say it will be fine... god I'm gonna cry, how long is the lifetime of IPv4 now :p and how would I make it compatible for IPv6... you really should have a website with lots of Google Adsense for all this!
Now you've given me an idea :) (though I have a sneaky suspicion I already grabbed a domain for it a while back .. )
 

Byron

New Member
God when will I actually get work done and get off this forum to blog about work, then maybe get some work done
 

mneylon

Administrator
Staff member
God when will I actually get work done and get off this forum to blog about work, then maybe get some work done
Well that's a good thing to say about the site if you actually want to spend time here :)
 
Status
Not open for further replies.
Top