Page 1 of 1

Redirect each visitor to my website

Posted: Thu Mar 05, 2015 4:27 pm
by charusarma
Hello all !
I would like to redirect each visitor to my website coming from a particular country, to other website. Does anyone know how I can do this?

Re: Redirect each visitor to my website

Posted: Tue Mar 24, 2015 3:52 pm
by Averyking
This solution may be help you

1.Download the latest Geo data and the class file

2.Copy the class file and the GeoIP data file into the same directory where the page is located (most of the time the root directory)

3.Include the class file inside your page and add the following code to request the country using the following code (below the include statements):

$gi = geoip_open('GeoIP.dat', GEOIP_MEMORY_CACHE);
$country = geoip_country_code_by_addr($gi, $_SERVER['REMOTE_ADDR']);
geoip_close($gi);

4.Define some country codes the "whitelist":

$my_countries = array('us', 'ca', 'gb', 'fr', 'de', 'nl');

5.Next place the following code below the $mycountries array:

if (!in_array(strtolower($country), $my_countries)) {
header('Location: some URL...');
exit;
}

Re: Redirect each visitor to my website

Posted: Thu Apr 09, 2015 10:21 am
by hollyjames879
You can forward your page to a different page by inserting the following piece of code in your <head> </head> tag:

<meta http-equiv="refresh" content="0; url=http://www.example.com/">