How to get the previous url using PHP

Nawaz picture Nawaz · Jan 11, 2011 · Viewed 139.4k times · Source

Suppose my site's url is given as hyperlink on some page on the internet; that page could be anything on internet - blog, orkut, yahoo, even stackoverflow etc, and someone clicks on it,and visited my site. So can we know, using php, the previous url from which the visitor came to my page?

Answer

BoltClock picture BoltClock · Jan 11, 2011

Use the $_SERVER['HTTP_REFERER'] header, but bear in mind anybody can spoof it at anytime regardless of whether they clicked on a link.