php - Redirecting incoming traffic from a referrer domain by country -
how can redirect incoming traffic specific domain when user specific country?
for example:
mexican traffic coming example.com site , chinese traffic coming newexample.com site , ...
thank you
[**edit more information**]
i'm looking code redirects incoming traffic following example domains if traffic specified country in front of domain in list. please include example domains , destination redirect url in code provide:
site1.com brazil >> redirect
site2.com mexico >> redirect
site3.com chili >> redirect
site4.com argentina >> redirect
site5.com columbia >> redirect
site6.com india >> redirect
site7.com india >> redirect
thanks
<?php $ip = $_server['remote_addr']; $url = "http://api.ipinfodb.com/v3/ip-city/?key=<api key>&ip=$ip&format=json"; $ch = curl_init(); // start curl curl_setopt($ch, curlopt_url, $url); // set url curl_setopt($ch, curlopt_returntransfer, true); // response variable curl_setopt($ch, curlopt_httpget, true); curl_setopt($ch, curlopt_fresh_connect, true); $response = curl_exec($ch); // connect , response curl_close($ch); $json_response = json_decode($response, true); echo "<pre>"; print_r($json_response); echo "</pre>"; ?>
the above code give location of user based on ip, redirect user based on location through if else
please note must sign here api key in order use this
Comments
Post a Comment