Forum Moderators: coopster

Message Too Old, No Replies

HTTP_REFERER in error pages

How can I found out who referred to a non-existing page

         

adb64

7:48 am on Feb 9, 2004 (gmt 0)

10+ Year Member



I've made my own error page for 404 errors (error404.php) and added it to my .htaccess file. So far so good.
This PHP script creates a log file containing all 404 errors, but I want to add the referrer from $HTTP_REFERER so I know who is referring to a page that doesn't exist anymore on my site. Just accessing $HTTP_REFERER won't work (this works only when from a local page on my site I access e.g. an image which no longer exists).

Anyone any idea how to solve this?

Thanx

seomike2003

1:37 am on Feb 10, 2004 (gmt 0)



$_SERVER['HTTP_REFFER']

Timotheos

6:03 am on Feb 10, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Mabye $_SERVER['REQUEST_URI']

http://www.webmasterworld.com/forum88/1578.htm [webmasterworld.com]

adb64

12:51 pm on Feb 10, 2004 (gmt 0)

10+ Year Member



Seomike2003 and Timotheus thanks,

but the $_SERVER['HTTP_REFERER'] is empty in a custom error page. But I did some research and discovered that this info is available via getenv('HTTP_REFERER').

Maybe this may help other people with the same problem.

Timotheos

5:26 pm on Feb 10, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hmmmm... I don't understand why getenv() would work while the other one didn't. Maybe something to do with php running in cgi vs apache module?

ergophobe

5:58 pm on Feb 10, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I have a custom error page that has a double redirect since I use mod_rewrite in .htaccess to make "friendly urls" and then if it can't find the page, the php script displays an error page.

It does not actually return a 404, but that's just because I don't make it send the 404 header.

In any case, in both Linux and Windows, this works fine:

echo $_SERVER['HTTP_REFERER']