我是 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 旋转链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!