Reputation: 397
I need to check referral url and if it's generated from Facebook redirect the user to a different webpage. How do I do that?
Upvotes: 1
Views: 901
Reputation: 360572
if (stripos(parse_url($_SERVER['HTTP_REFERER'], PHP_URL_HOST), 'facebook') !== FALSE) {
header('Location: differentwebpage.html');
}
Upvotes: 1
Reputation: 163272
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.
Upvotes: 3