I'm making a page 404 with button for user report that site have a problem. The idea is when user click on button, I receive a email with information of the last page accessed...
The problem is that I'm using the php variable '$_SERVER['HTTP_REFERER']' and this ever return a null value. I found this question (In what cases will HTTP_REFERER be empty) and I came to the conclusion that this variable is not the solution.
This is my .htacess
RewriteEngine on
ErrorDocument 404 http://example.com/erro.php
#ErrorDocument 404 /erro.php #this doesnt work... redirect doesnt work
On page erro.php I have code with function email that are working without problem, but I need some manner to take last accessed page that generate error.
On page erro.php I'm trying use:
echo $_SERVER['HTTP_REFERER']; // return null value
echo $_SERVER['REQUEST_URI']; // return page http://example.com/erro.php
I try use alternative with jQuery (https://stackoverflow.com/a/2415645/2761794):
On page erro.php
$(document).ready(function() {
var referrer = document.referrer;
alert(referrer); // return null value
});
Some suggestion to take last accessed URL on page erro.php for send by email?