You can enable IP Geolocation to have CloudFlare geolocate visitors to your website and pass the country code to you.
Redirect web traffic based on Country origin to subdomain or to different web site.

You will find the IP geolocation option by going to:
Webiste –>CloudFlare Settings –>IP Geolocation

Direct link is:
https://www.cloudflare.com/cloudflare-settings?z=YOURSITE

Once enabled, Cloudflare will then add a header called “CF-IPCountry” to all requests to your website.

Redirect web traffic based on Country origin

Here are a couple of examples of how to access/store this value:

$country_code = $ENV{"HTTP_CF_IPCOUNTRY"}; # to access in Perl
$country_code = $_SERVER["HTTP_CF_IPCOUNTRY"]; // to access in PHP

CloudFlare includes this information for both IPv4 and IPv6 addresses

In your website code capture that header and redirect traffic.
Redirect web traffic based on Country origin PHP sample:

$country_code = $_SERVER["HTTP_CF_IPCOUNTRY"];

if($country_code=="US"){
$location='http://www.mysite.com/us';
}elseif($country_code=="UK"){
$location='http://www.mysite.com/uk';
}else{
$location='http://www.mysite.com/us';
}
header("location:$location");
exit;

Update:

ASP.NET example:
http://netjunky.net/redirect-web-traffic-with-cloudflare-and-asp-net/

Subscribe To Our Newsletter

Subscribe To Our Newsletter

Join our mailing list to receive the latest news and updates from our team.

You have Successfully Subscribed!