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?
Redirect each visitor to my website
Re: Redirect each visitor to my website
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;
}
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;
}
-
- Posts: 7
- Joined: Thu Jan 22, 2015 3:57 pm
Re: Redirect each visitor to my website
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/">
<meta http-equiv="refresh" content="0; url=http://www.example.com/">