$ _SERVER [“REQUEST_URI”]在htaccess重定向后随机清空

When a user try to visit a file which doesn't exist, I use a .htaccess redirect to 404.php which saves the wrong URL of the missing file into database.

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) /404.php [L]

In 404.php I'm inserting into database $_SERVER["REQUEST_URI"].

But for some reason in some ocassions is the REQUEST_URI empty. Even If I try to open the same URL over and over again then for example 1 in 10 times it will be empty.

The website using HTTPS everywhere, Debian 3.16.59-1, Apache 2.0, PHP Version 5.6.38 (don't ask me why, it's not under my control).

Where can be the problem? Can it be a bug in used technologies? Bug in browser? (newest Chrome) Or am I just missing something?