Q:

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

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?

A:

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.

