I\'ve used the code below to create a custom 404 message (page not found) using a .htaccess file.
RewriteEngine On ErrorDocument 404 https://%{HTTP_HOST}/404.p
Remove http:// from 404 handler and have it like this:
http://
ErrorDocument 404 /404.php
The URL that is causing 404 is available to you in 404.php using:
404.php
$_SERVER["REQUEST_URI"]
When http:// ise used in 404 handler server performs full redirection and you loose original REQUEST_URI.
REQUEST_URI