开发者

What is the best way to get the URL of a 404'd file after redirect?

开发者 https://www.devze.com 2022-12-19 07:40 出处:网络
I\'m working with a PHP site that needs to log errors to a database. As such, I\'ve set up a .htaccess file as follows:

I'm working with a PHP site that needs to log errors to a database. As such, I've set up a .htaccess file as follows:

ErrorDocument 404 /404.php

404.php contains all of the logging functions necessary to insert the log into the database. What I'm having problems with is retrieving the URL of the file that triggered the 404.

Here are 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? Everything that I've read recommends the HTTP_REFERER item开发者_StackOverflow中文版, but it doesn't seem to exist.

Thanks in advance.


REQUEST_URI is meant to contain the requested URL path and query.

0

精彩评论

暂无评论...
验证码 换一张
取 消