I have a custom 404 page declared via .htaccess on an Apache server.
My question: Is there a way with PHP to grab an incorrectly-entered URL?
I wish to somehow grab the incorrect URL typed in that accessed the 404.php in the first place and assign it to a $var for use in an e-mail.
Using magic constants like FILE or extracting the current script name via $_SERVER[‘SCRIPT_NAME’] obviously returns 404.php since it the valid file name name executing the script.
I don’t know where $_ENV gets it’s data from but AFAIK $_SERVER gets its data from the server on which php is running. It does seem strange that there is $_SERVER and $_ENV that duplicate each other, my guess is that there is some difference behind the scenes as to how they get the information.
$_ENV gets it’s information from the “environment” (you know, the space where PATH and stuff are also set).
It’s less certain to rely on $_ENV (some servers I worked have an empty array for $_ENV !) whereas $_SERVER has never been a problem for me.