How can you redirect visitors to a specific page based on their referral source using PHP?
To redirect visitors to a specific page based on their referral source using PHP, you can check the HTTP referer header and then use a conditional statement to redirect the user accordingly. This can be useful for tracking where your website traffic is coming from and providing a tailored experience for users based on their referral source.
$referer = $_SERVER['HTTP_REFERER'];
if (strpos($referer, 'google.com') !== false) {
header('Location: http://example.com/google-page.php');
exit();
} elseif (strpos($referer, 'facebook.com') !== false) {
header('Location: http://example.com/facebook-page.php');
exit();
} else {
header('Location: http://example.com/default-page.php');
exit();
}