Hi everyone! I donīt know if I should ask this on php or apache section so I decide to use webmaster general...
What I need to know is if I can redirect a visitor based on his country.
I mean, I know I can do that with a php file, calling the GeoIp database, but to do it I have to put it on my domain root and mysite.com becames a redirection script to mysite.com/uk and mysite.com/us, etc.
Hereīs the php example script: <?php
require_once("geoip/geoip.inc");
$gi = geoip_open("geoip/GeoIP.dat",GEOIP_STANDARD);
$country_code = geoip_country_code_by_addr($gi, $_SERVER['REMOTE_ADDR']);
geoip_close($gi);
if($country_code == 'fr')
{
header("HTTP/1.1 301 Moved Permanently");
header('Location: http://mysite.com/fr/');
}
else
{
header("HTTP/1.1 301 Moved Permanently");
header('Location: http://mysite.com/en/');
}
?>
What I want (and thatīs where my doubt about posting on php or apache section came), is to know if itīs possible to redirect using .htaccess or any other method, or just with the php method I refered above.
Because what I want is something like this: - visitors click on a link to mysite.com and if it is US citizen nothing happens and he enter on mysite.com, if itīs French or Brazilian, enter on mysite.com/international/
Besides that, if possible, I also want this: - visitor click on a link to mysite.com/hosting/ and if it is a US citizen nothing happens and he enter on mysite.com/hosting/, if itīs French or Brazilian, enter on mysite.com/hosting/international/
Conclusion: - for every page on my site, I want to have a mirror version (with a no index tag), just with different banners and different small portions of text for where I want to redirect all my international traffic.
If anyone could help me I would be very appreciated.