Welcome Guest, Not a member yet? Register   Sign In
redirect domain based on country

(This post was last modified: 11-10-2018, 10:23 AM by visualsol.)

There's not really any advantage I can think of to run this logic server-side.
I would just use javascript/jquery and then you just use an API to resolve the visitor country code by IP and redirect to the corresponding URL :

$.getJSON("http://api.db-ip.com/v2/free/self").then(function(addrInfo) {
  if (addrInfo.countryCode== "US") {
      document.location = "http://us.example.com";
  } else if (...) {
      // handle other cases
  } else {
      document.location = "http://example.com";

Should you still want a server-side api call, here is a PHP library for the demonstrated api: https://github.com/dbip/api-client

Messages In This Thread
redirect domain based on country - by menilanjan - 10-24-2018, 05:40 AM
RE: redirect domain based on country - by visualsol - 11-10-2018, 10:21 AM

Theme © iAndrew 2016 - Forum software by © MyBB