Skip to content Skip to sidebar Skip to footer

Acquiring Referral Url After A Php Redirect

This is the scenario: a user land on a page which redirects him at certain conditions with the following php lines header('Location: /access/details/index.php'); die(); The proble

Solution 1:

There is no way to tell the browser what URL to use for the referrer. Instead, you can pass the referrer as a get parameter in the redirect.

header("Location: /access/details/index.php?referrer=" . urlencode($_SERVER['HTTP_REFERER']));

Retrieve the previous referrer on your /access/details/index.php script by accessing the $_GET super global

$referrer = $_GET['referrer'];

Another option would be to skip the redirect altogether and do a forward. This keeps the current referrer intact.

include("/access/details/index.php");
die();

Post a Comment for "Acquiring Referral Url After A Php Redirect"