Search code examples
.htaccesscustom-error-pages

htaccess - how to include the (incorrect) file name with the 404 redirect


I have an htaccess file with a 404 redirect, like:

ErrorDocument   404 /?404

in which a 404 message is presented. In order to take care of things depending on what file name / URI caused the 404, I would need to know the (incorrect) file name in my 404 PHP file. How is that done...?

Novice-like, I tried

ErrorDocument   404 /?404&p=%{REQUEST_URI}

which did not work. Is there a way to include the file name?


Solution

  • The requested file (that did not exist) was of course accessible in the 404 file by:

    $_SERVER["REQUEST_URI"]
    

    Problem solved.