I am working with a PHP website that should log errors in a database. So I installed the .htaccess file as follows:
ErrorDocument 404 /404.php
404.php contains all the logging functions needed to insert a log into the database. I'm having trouble getting the URL of the file that called 404.
Here is the contents of the $ _SERVER superglobal array:
[HTTP_HOST] => {omitted}
[HTTP_USER_AGENT] => Mozilla / 5.0 (Windows; U; Windows NT 5.1; en-US; rv: 1.9.1.7) Gecko / 20091221 Firefox / 3.5.7
[HTTP_ACCEPT] => text / html, application / xhtml + xml, application / xml; q = 0.9, * / *; q = 0.8
[HTTP_ACCEPT_LANGUAGE] => en-us, en; q = 0.5
[HTTP_ACCEPT_ENCODING] => gzip, deflate
[HTTP_ACCEPT_CHARSET] => ISO-8859-1, utf-8; q = 0.7, *; q = 0.7
[HTTP_KEEP_ALIVE] => 300
[HTTP_CONNECTION] => keep-alive
[PATH] => / usr / local / bin: / usr / bin: / bin
[SERVER_SIGNATURE] =>
[SERVER_SOFTWARE] => Apache / 2.2.8 (Ubuntu)
[SERVER_NAME] => {omitted}
[SERVER_ADDR] => {omitted}
[SERVER_PORT] => 80
[REMOTE_ADDR] => {omitted}
[DOCUMENT_ROOT] => {omitted}
[SERVER_ADMIN] => [no address given]
[SCRIPT_FILENAME] => /404.php
[REMOTE_PORT] => 19274
[GATEWAY_INTERFACE] => CGI / 1.1
[SERVER_PROTOCOL] => HTTP / 1.1
[REQUEST_METHOD] => GET
[QUERY_STRING] =>
[REQUEST_URI] => /404.php
[SCRIPT_NAME] => /404.php
[PHP_SELF] => /404.php
[REQUEST_TIME] => {omitted}
Any suggestions? All I read recommends the HTTP_REFERER element, but it does not seem to exist.
Thanks in advance.
source share