title: How to find referrer URL while using htaccess 404 redirect?
body: <p>I've used the code below to create a custom 404 message (page not found) using a .htaccess file.  </p>
  
  <pre><code>RewriteEngine On
  ErrorDocument 404 https://%{HTTP_HOST}/404.php
  </code></pre>
  
  <p>It works well, but I want to know what was the wrong URL that caused this redirection. In other words, I need to fetch <strong>HTTP referer</strong> while user is in 404.php. So I have used <code>$_SERVER['HTTP_REFERER']</code> in 404.php, but it does not return anything.<br>
  Where did I have mistakes? And what is your solutions to solve this problem?</p>