2015-10-05 35 views
0

我是geoplugin.class將CA用戶重定向到特定鏈接。使用Geoplugin旋轉鏈接

現在,代碼只允許我將用戶重定向到1個網站。我想修改這個代碼,這樣我就可以將用戶重定向到任何

link1.com

link2.com

link3.com

有沒有人有一個快速的修改?

預先感謝您。

<?php 

    require_once('geoplugin.class.php'); 
    $geoplugin = new geoPlugin(); 
    $geoplugin->locate(); 


    $geo_region = $geoplugin->region; 

    switch($geo_region) { 
     case 'CA': 
      header('Location: http://www.link1.com'); 
      exit; 



     default: // exceptions 
       header('Location: http://www.everyoneelsegoeshere.com'); 
       exit; 

     } 

?> 

回答

0

試試這個:

require_once('geoplugin.class.php'); 
$geoplugin = new geoPlugin(); 
$geoplugin->locate(); 
$geo_region = $geoplugin->region; 



switch($geo_region) { 
    case 'CA': 
    $links = array('link1.com','link2.com','link3.com'); 
    header('Location: http://'.$links[array_rand($links)]); 
    exit; 
    default: // exceptions 
    header('Location: http://www.everyoneelsegoeshere.com'); 
    exit; 
}