I see now you were asking about a redirect rather than referrer. I think the best way to do that is to add a query string to the end of the redirect url (if you're able to): e.g.
header('Location: http://example.com?a=b');
Then
if (isset($_GET['a']) && ($_GET['a'] == 'b')) {
echo '<a href="one_page.php">click</a>';
} else {
echo '<a href="another_page.php">click</a>';
}