GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Webmaster Q & Fuckin' A (https://gfy.com/forumdisplay.php?f=27)
-   -   redirecting traffic by country (https://gfy.com/showthread.php?t=1057257)

versa 02-11-2012 05:42 PM

redirecting traffic by country
 
Hello,
Tried the following geolite MaxMind and it redirected all my traffic to the redirect URL instead of just DE traffic. I just want DE (German) traffic redirected right now and if not DE continue on.

<?php
require_once('geoip.inc');

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

$my_countries = array('de');
if (!in_array(strtolower($country), $my_countries))
{
header('Location: http://www.google.com);
}
exit;
}
?>

Got the code from here:
http://www.warriorforum.com/programm...s-country.html

Help!
(-:

baryl 02-11-2012 07:41 PM

Change
if (!in_array(strtolower($country), $my_countries))
to
if (in_array(strtolower($country), $my_countries))

remove the '!'

versa 02-11-2012 11:41 PM

That did it, many thanks!

baryl 02-12-2012 09:49 AM

Sure, I had the exact same problem before. :thumbsup


All times are GMT -7. The time now is 10:51 PM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123