Skip to content

Instantly share code, notes, and snippets.

@spydon
Created October 17, 2013 00:54
Show Gist options
  • Save spydon/7017579 to your computer and use it in GitHub Desktop.
Save spydon/7017579 to your computer and use it in GitHub Desktop.
domain-redirect.phtml
<?php
if(Mage::getStoreConfig('geoip/domain/enabled'))
{
$code=Mage::helper('egrovegeoip')->getCurrentCountry();
$url=Mage::getModel('geoip/domain')->getUrlByCountry($code);
$request_headers=apache_request_headers();
$request_host=$request_headers['Host'];
header("X-CODE: $code");
header("X-URL: $url");
header("X-HOST: $request_host");
header("X-REQKEYS: $_SERVER[REQUEST_URI]");
$path_components = explode("/", substr($_SERVER['REQUEST_URI'], 1));
$path_prefix = $path_components[0];
$maybe_path = ($path_prefix === "") ? "" : "/$path_prefix";
if($url && substr($url, 7) !== ($request_host . $maybe_path))
{
while (ob_get_status())
{
ob_end_clean();
}
header("Location: $url");
exit;
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment