Rotate Links Using Geoplugin

前端 未结 1 2032
说谎
说谎 2021-01-27 12:03

I\'m geoplugin.class to redirect CA users to a specific link.

Right now the code only allows me to redirect the user to 1 website. I would like to modify this code so I

相关标签:
1条回答
  • 2021-01-27 12:17

    Try This one:

    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;
    }
    
    0 讨论(0)
提交回复
热议问题