将我的一些网站流量重定向到另一个URL,基于referrer

时间:2017-04-21 20:10:24

标签: php regex .htaccess web url-redirection

我的网站是http://www.example.com

我想将15%的Google / Bing传入流量重定向到我的网站,转到子域名,例如http://beta.example.com

我可以使用php,htaccess,...

感谢您的帮助。

1 个答案:

答案 0 :(得分:0)

这样的东西?

$referer = $_SERVER['HTTP_REFERER'];

if(strpos($referer, 'bing') !== false || strpos($referer, 'google') !== false) {

    if(rand(0, 100) < 15) {
        header('Location: http://beta.example.com/');
        exit();
    }
}