title: Maxminds GeoIP php Redirect according to country code
body: <p>I have been working on this for a week now and have tried it with my .htaccess file but even this did not work basically in firefox its saying...</p>
  
  <blockquote>
    <p>The page isn't redirecting properly      Firefox has detected that the
    server is redirecting the request for this address in a way that will
    never complete.
            This problem can sometimes be caused by disabling or refusing to accecp cookies.</p>
  </blockquote>
  
  <p>and in chrome its saying.....</p>
  
  <blockquote>
    <p>This web page has a redirect loop The web page at
    <a href="https://www.website.com/row/index.php" rel="nofollow">https://www.website.com/row/index.php</a> has resulted in too many
    redirects. Clearing your cookies for this site or allowing third-party
    cookies may fix the problem. If not, it is possibly a server
    configuration issue and not a problem with your computer.</p>
  </blockquote>
  
  <p>I uploaded the GeoIP.dat and geoip.inc files from the GeoIP PHP API from Maxminds website to a directory on my hosting then i edited my index.php file with the following php code block....</p>
  
  <pre><code>&lt;?php
  require_once("geoIP/geoip.inc");
  $gi = geoip_open('geoIP/GeoIP.dat', GEOIP_MEMORY_CACHE);
  $country = geoip_country_code_by_addr($gi, $_SERVER['REMOTE_ADDR']);
  // prints the country code  your visitor is in
  $my_countriesrow = array('AD','AE','AF','AG','AI'.....ect);
  $my_countrieseuro = array('AN','AT','BA','BE','BG','BY','CH'.....ect);
  /* $my_country = array('GB','UK'); */
  if (!in_array(strtolower($country), $my_countriesrow)) {
  header('Location: https://www.website.com/row/index.php');
  exit();
  }
  else if(!in_array(strtolower($country), $my_countrieseuro)){
  header('Location: https://www.website.com/euro/index.php');
  exit();
  }
  else {
  header('Location: https://www.website.com/index.php');
  exit();
  }
  // the end
  geoip_close($gi);
  ?&gt;
  </code></pre>
  
  <p>I think it may have something to do with my .htaccess file as it includes this in it.... </p>
  
  <pre><code># Make all requests have www in them
   RewriteEngine On
   RewriteCond %{HTTP_HOST} ^website\.com
   RewriteRule ^(.*)$ https://www.website.com$1 [R=permanent,L]
  </code></pre>
  
  <p>dont know what else to do have already pulled out all my hair on this! many thanks in advace guys!</p>
  
  <p>Regards
  -Phillip</p>