开发者

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

开发者 https://www.devze.com 2023-04-08 18:56 出处:网络
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\'].

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

精彩评论

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