使用 Geoplugin 旋转链接 [英] Rotate Links Using Geoplugin

查看:24
本文介绍了使用 Geoplugin 旋转链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 geoplugin.class,用于将 CA 用户重定向到特定链接.

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

现在代码只允许我将用户重定向到 1 个网站.我想修改此代码,以便可以将用户重定向到任一

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

link1.com

link2.com

link3.com

有人对此有快速修改吗?

Does anyone have a quick modification for this?

提前谢谢你.

<?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;

         }

 ?>

推荐答案

试试这个:

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;
}

这篇关于使用 Geoplugin 旋转链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆