如何在php中记录用户错误的输入URL

I have a question for how to record a manually entered wrong url. The scenario is: a user wants to visit mywebsite.com/page.php, but incorrectly entered mywebsite.com/page2.php, which does not exist.

My question is: how to record the user's input page2.php? (Note: I am not asking how to redirect:)

Thanks!

Use htaccess

ErrorDocument 404 /getError.php

And in getError.php get current URL

echo 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; // Save This