oracle765 Posted October 31, 2015 Share Posted October 31, 2015 (edited) Hi Professionals I have no code to show as I am still confused as to wether or not PHP is the right way forward Here is my problem I have 3 websites UK, AU and NZ What I am looking to do is serve the correct website to UK users and New Zealand users, it does not matter which country the AU users are in as they can have this website served to them in any country with the exception of the two mentioned above Would PHP be the best for this or is there a better way of doing it I have the correct hreflang tags in place I am just stuck on the Geo Location Serving part I am looking to do similar to what trivago do or compare the market do for different countries Thanks in advance professionals Alan Edited October 31, 2015 by oracle765 Quote Link to comment https://forums.phpfreaks.com/topic/298951-geo-location-serving-a-different-website/ Share on other sites More sharing options...
requinix Posted October 31, 2015 Share Posted October 31, 2015 Is there a problem with prompting the user for which site to use? For example, what UPS and FexEx do. There's a pretty substantial advantage to prompting in that the user controls which site they use. With that said, defaulting and then offering a way to switch shouldn't be too bad. Otherwise what you're looking for is generically called geolocation. Quote Link to comment https://forums.phpfreaks.com/topic/298951-geo-location-serving-a-different-website/#findComment-1524940 Share on other sites More sharing options...
QuickOldCar Posted October 31, 2015 Share Posted October 31, 2015 (edited) You can use something like this http://dev.maxmind.com/geoip/geoip2/javascript/tutorial/ Some people disable javascript, yes is a lot of sites that rely on javascript but they do it anyway. In that case can do it server side with php use curl/file_get_contents and a geo api , or have a local geo database use a switch or if/else to determine which site needed to load exclude the current site they are currently visiting perform a header redirect to your new location unless they are already at it I would set the location in a session or a cookie so don't have to keep doing the additional work each page load. Check if the session or cookie exists first, if not run the geoip code One thing you have to work out is if I was to visit from USA which site am I getting sent to. Your site isn't handling every possible location, if is not one of the 3 you mentioned make one the default. Edited October 31, 2015 by QuickOldCar Quote Link to comment https://forums.phpfreaks.com/topic/298951-geo-location-serving-a-different-website/#findComment-1524941 Share on other sites More sharing options...
0x00 Posted October 31, 2015 Share Posted October 31, 2015 I played with maxmind a year or so ago, set it up in a local db and ran tests. On random generation tests in general a third of addresses weren't in it, yes they may not be assigned, but so many over numerous tests, so I ran ran some randomly collected addresses, there were even Google ip's which weren't in it, never mind my own! Also when tested with Tor and specified exit nodes, it often got it wrong. Yes, it was the free version. Quote Link to comment https://forums.phpfreaks.com/topic/298951-geo-location-serving-a-different-website/#findComment-1525006 Share on other sites More sharing options...
oracle765 Posted October 31, 2015 Author Share Posted October 31, 2015 thanks everyone I will look into this, although what you have said (0x00) had tended to scare me away from maxmind thanks Quote Link to comment https://forums.phpfreaks.com/topic/298951-geo-location-serving-a-different-website/#findComment-1525018 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.