When a web page is accessed by a link from some other page, the address of the other page (the “referring page”) is made available to the web server. We can pick that information up from logs or as the page is being displayed. For example, if we have Server Side Includes or php, we can pickup the referring page from an environment variable. Here’s a snippet of Perl code that does that:
Yes, there’s a missing R in HTTP_REFERER. Yes, that’s wrong, but that’s what the variable is so that’s what you use.