2016-08-09 87 views
0

Ich habe eine Website namens smarkmart. Ich möchte es auf drei Arten umleiten. 1. In Indien sollte es auf sein www.smarkmart.in 2. In USA auf www.smarkmart.com 3. Übriges anderen sollte es auf www.smarkmart.comUmleiten meiner Website von zwei Domäne Tlds verursacht eine Infinite Redirect-Schleife

Hier sollte mein Code für Umleitung

session_start(); 
require 'geoplugin.class.php'; 
$geoplugin = new geoPlugin(); 
$geoplugin->locate(); 
if (isset($_SESSION['pricetype'])) { 
    unset($_SESSION['pricetype']); 
} 
// create a variable for the country code 
$var_country_code = $geoplugin->countryCode; 
// redirect based on country code: 
if (!isset($_SESSION['pricetype'])) { 
    if ($var_country_code == "US") { 
     header('Location: http://www.smarkmart.com'); 
     $_SESSION['pricetype'] = "priceinr"; 
    } 
    if ($var_country_code == "IN") { 
     header('Location: http://www.smarkmart.in'); 
     $_SESSION['pricetype'] = "priceusd"; 
    } else { 
     header('Location: http://www.smarkmart.com'); 
     $_SESSION['pricetype'] = "priceinr"; 
    } 
} 
$pricetype = $_SESSION['pricetype']; 

Dies verursacht eine Infinet-Schleife. Jede Hilfe wäre willkommen. Danke im Voraus.

+0

Dies ist nicht SEO und benutzerfreundlich. werfen Sie einen Blick auf: https://support.google.com/webmasters/answer/182192?hl=de –

Antwort

0

Sie leiten nur, wenn $ _SESSION [ ‚Preisart‘] null ist, aber Sie unset es am Anfang des Skripts:

if(isset($_SESSION['pricetype'])) 
{ 
    unset($_SESSION['pricetype']); 
}