I'm currently building an Error 404 page for a website project. People are redirected to this page using .htaccess if the page they requested can't be found.
I want to display on the custom Error page the URL or link that they came from, but I can't figure out how. I had a go at this:
<?php
function curPageURL() {
$pageURL = 'http';
if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
return $pageURL; // Finally, Returns the page URL
}
?>
And then I added the PHP function to my Error page:
The Page You Came From Was: <?php echo curPageURL(); ?>
Sadly, all this does in the end is display the URL of my Error page, and not the one where users were just redirected from.
Anyone have any ideas?
Adam.