2016-08-09 3 views
0

私はsmarkmartという名前のWebサイトを持っています。私は3つの方法でそれをリダイレクトしたい。 1.インドのそれはそれはここでwww.smarkmart.com私のサイトを2つのドメインのtldsからリダイレクトすると、リダイレクトループが発生します

にする必要があります他のwww.smarkmart.com 3.休憩にする必要があり、米国ではwww.smarkmart.in 2にする必要があります私ですリダイレクトコード -

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']; 

これはループを引き起こしています。どんな助けもありがとう。前もって感謝します。あなたはたったの$ _SESSION [「pricetype」]場合はリダイレクト

+0

これはSEOとユーザーフレンドリーではありません。次のURLをご覧ください:https://support.google.com/webmasters/answer/182192?hl=ja –

答えて

0

はnullですが、あなたはスクリプトの開始時に、それを設定解除:

if(isset($_SESSION['pricetype'])) 
{ 
    unset($_SESSION['pricetype']); 
} 
関連する問題