Redirect by country
Im using this code:
<?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('us', 'ca', 'gb', 'fr', 'de', 'nl'); if (!in_array(strtolower($country), $my_countries)) { header('Location: http://www."ALL"TRAFFICURLGOESHERE.whatever'); } else { header('Location: http://www."SELECTEDCOUNTRIES"URLGOESHERE.whatever'); } ?>
http://geolite.maxmind.com/download/...y/GeoIP.dat.gz
http://geolite.maxmind.com/download/.../php/geoip.inc
It works but only for one group or one country. This script is sending the visitors from selected countries to second url and other IP's to first url.
I need a code that will send different countires to different URL's. I need to set up few countries (one url per country) and one url for other countries, that are not metioned in the code.
For example:
USA -> url1
GB -> url2
CA -> url3
All other countries -> url4
Can anyone help me? I think its simple for advenced coder, but I have 0 experience in PHP. I think that its possible to use these two files with data that Ive metioned.
Help will be much appreciated.
-
mywebwork -
Thanks
{{ DiscussionBoard.errors[2823761].message }} -
-
phpbbxpert -
Thanks - 1 reply
{{ DiscussionBoard.errors[2823808].message }}-
sqallpl -
Thanks - 1 reply
{{ DiscussionBoard.errors[2874632].message }}-
bort27 -
Thanks - 1 reply
{{ DiscussionBoard.errors[2896232].message }}-
purelogic -
Thanks
{{ DiscussionBoard.errors[2898325].message }} -
-
-
-