How can I get the referer string in PHP?
What is the referer?
How can I find out what site a visitor has come from?
Dec 26th, 2005 03:42
Praveen Kumar Kukkapalli, Nathan Wallace, unknown unknown,
Better to use $_SERVER["HTTP_REFERER"] to know the referer URL.
If the user followed a link to the current page then the referer is the
URL that the user has come to the current page from. If they typed in
the URL directly or came from their bookmarks then the referer is
PHP makes the referer automatically available in the variable:
$HTTP_REFERER - the url the client just came from
The referer is actually stored in an environment variable which you can
get using getenv():
To see what information like this is available create a page that
<?php phpinfo() ?>
That will show you all of the environment variables that are available.