Redirect website traffic based on country

hehe2444

Regular Member
Joined
Feb 24, 2017
Messages
496
Reaction score
255
As the title says I have 2 options to do that.

Making a link with rebrandly and redirect tier 1 to an offer and tier 3 to another offer.

The second one is with cloudflare. They have an option to do this also.

Wanted to know if there is any other option?

Thanks
 
Use a geo IP database of your choice and implement some code into your website with PHP or JavaScript.
 
Where is the redirect option on Cloudflare ? For some reason i can find only block specific countries.
 
Cloudflare passes the country shortcode of the visitor to the server, $_SERVER['HTTP_CF_IPCOUNTRY '];

All what you have to do is create a single php file and use php if conditions this is an example:

<?php

$country_code = mb_strtoupper($_SERVER["HTTP_CF_IPCOUNTRY"], 'UTF-8');

//United States Redirect
if($country_code == "US"):
header('Location: http://site1.com');
exit();
endif;

//France Redirect
if($country_code == "FR"):
header('Location: http://site2.com');
exit();
endif;

//Canada Redirect
if($country_code == "CA"):
header('Location: http://site2.com');
exit();
endif;

//You Cann Duplicate The Same Syntax here Just Replace Country Code

//Default Redirect If User Is From A Non Defined Country
header('Location: http://site2.com');
 
Cloudflare passes the country shortcode of the visitor to the server, $_SERVER['HTTP_CF_IPCOUNTRY '];

All what you have to do is create a single php file and use php if conditions this is an example:

<?php

$country_code = mb_strtoupper($_SERVER["HTTP_CF_IPCOUNTRY"], 'UTF-8');

//United States Redirect
if($country_code == "US"):
header('Location: http://site1.com');
exit();
endif;

//France Redirect
if($country_code == "FR"):
header('Location: http://site2.com');
exit();
endif;

//Canada Redirect
if($country_code == "CA"):
header('Location: http://site2.com');
exit();
endif;

//You Cann Duplicate The Same Syntax here Just Replace Country Code

//Default Redirect If User Is From A Non Defined Country
header('Location: http://site2.com');


How reliable is to use cloudflare for this. It's working 100% on every IP?
 
Back
Top