重定向后获取404文件的URL的最佳方式是什么?
我正在使用一个需要将错误记录到数据库的PHP站点。 因此,我已经建立了一个.htaccess文件,如下所示:
ErrorDocument 404 /404.php
404.php包含将日志插入数据库所需的所有日志记录功能。 我遇到的问题是检索触发404的文件的URL。
以下是$ _SERVER超全局数组的内容:
[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}
有什么建议么? 我读过的所有内容都推荐使用HTTP_REFERER项目,但似乎并不存在。
提前致谢。
REQUEST_URI旨在包含请求的URL路径和查询。
链接地址: http://www.djcxy.com/p/48801.html上一篇: What is the best way to get the URL of a 404'd file after redirect?