开发者

How to check referral url and re-direct based on that?

I need to check referral url and if it's generated from Faceboo开发者_运维知识库k redirect the user to a different webpage. How do I do that?


Take a look in $_SERVER['HTTP_REFERER'].

You can then use parse_url() to get the hostname, and compare the domain to a list of known Facebook domains.

Beware, the referer isn't required, and isn't always set. So, don't use it as any kind of security.


if (stripos(parse_url($_SERVER['HTTP_REFERER'], PHP_URL_HOST), 'facebook') !== FALSE) {
   header('Location: differentwebpage.html');
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜