0

I am using this geoip redirect extension for magento. https://github.com/magento-hackathon/Sandfox_GeoIP

It works well and I use a file called geoipredirect.php to redirect to store views/websites (called via index.php):

<?php
Mage::app();
$geoIP = Mage::getSingleton('geoip/country');
$country = $geoIP->getCountry();

if (strcmp($country,'DE') == 0) {
    $mageRunType = 'website';
    $mageRunCode = 'website_de';
}

elseif(strcmp($country,'AT') == 0) {
    $mageRunType = 'website';
    $mageRunCode = 'website_at';
}

else
{
    $mageRunType = 'website';
    $mageRunCode = 'base';
}
Mage::reset();

Now I need some some links containing subfolders NOT to be redirected. I have added below code. But the listed URL that includes the subfolder still gets redirected. Any idea whats wrong with the code?

<?php
Mage::app();
$geoIP = Mage::getSingleton('geoip/country');
$country = $geoIP->getCountry();

if( ! is_super_admin() && current_page_url() != 'https://domain.com/subfolder/' ){
        if ($country == "CH" ) {
        redirect("https://domain.com/subfolder/");
        exit;
 }


elseif (strcmp($country,'DE') == 0) {
    $mageRunType = 'website';
    $mageRunCode = 'website_de';
}

elseif(strcmp($country,'AT') == 0) {
    $mageRunType = 'website';
    $mageRunCode = 'website_at';
}


else
{
    $mageRunType = 'website';
    $mageRunCode = 'base';
}
Mage::reset();
0

I've solved this finally by using Amastys GeoIp extension.

| improve this answer | |
  • Hi, Is that extension supports varnish cache enabled site? – Ask Bytes Apr 9 '19 at 9:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.