Created
August 6, 2020 11:31
-
-
Save srokatonie/bda12a1ff046e253a04c966dec63bae8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$redirectFacebook = false; | |
// Fix stupid Facebook button restriction by checking the referer link | |
// and if comes from FB, go to specifified | |
if ($redirectFacebook) { | |
$host = "https://domain.com/"; | |
$uri = "final-uri/"; | |
$location = "Location: " . $host . $uri; | |
$refererUrl = strtolower($_SERVER['HTTP_REFERER']); | |
$refererDomain = strpos($refererUrl, 'facebook'); | |
$whatINeed = explode('/', $_SERVER['REQUEST_URI']); | |
$whatINeed = $whatINeed[1]; | |
if ($refererDomain !== false && $whatINeed != $uri) { // prevent circular thing | |
if (isset($_GET["fbclid"])) { | |
echo "Redirect to " . $_GET["fbclid"]; | |
$location = $location . "?fbclid=" . $_GET["fbclid"]; | |
} | |
header($location, true, 302); | |
exit; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment