...

View Full Version : HELP! 404 Error page with previous url displayed



disto
08-23-2006, 01:39 PM
hi im creating a 404 error page and i want the url to be displayed.

i did some searching around and found http://www.sitepoint.com/forums/showthread.php?t=6032&goto=nextoldest

i followed this and created the file 404.php


<html>
<body vLink=#ff0000 aLink=#ff0000 link=#ff0000 bgColor=#ffffff>
404 Error
<br><br><font id=text>sorry an error has occoured, we have automatically be notified of this error.
<?php $badurl = "http://" . $SERVER_NAME . $REDIRECT_URL;
$message = "A bad link to $badurl was encountered on $HTTP_REFERER.";
echo $message; ?>
<br><br>
<a href="#" onClick="history.back()">go back</a>
</body>
</html>


using the .htaccess file


ErrorDocument 500 /files/500.html
ErrorDocument 404 /files/404.php
ErrorDocument 401 /files/401.html
ErrorDocument 403 /files/403.html


when the page is displayed it shows
404 Error

sorry an error has occoured, we have automatically be notified of this error. A bad link to http://URL.../files/404.php was encountered on http://URL.../link.html.

go back

so its displaying the URL that contains the error but not which URL the link was to. can anyone help? whats wrong with the $REDIRECT_URL

eak
08-23-2006, 03:45 PM
try these other globals.


$_SERVER['REDIRECT_UNIQUE_ID']
$_SERVER['REDIRECT_SCRIPT_URL']
$_SERVER['REDIRECT_SCRIPT_URI']
$_SERVER['REDIRECT_SITE_ROOT']
$_SERVER['REDIRECT_SITE_HTMLROOT']
$_SERVER['REDIRECT_SITE_CGIROOT']
$_SERVER['REDIRECT_STATUS']
$_SERVER['REDIRECT_QUERY_STRING']
$_SERVER['REDIRECT_URL']

disto
08-24-2006, 12:38 AM
could you give and example of one of the possiblities

where do i need to place it?
would it be (for the $_SERVER['REDIRECT_UNIQUE_ID'])


<?php $badurl = "http://" . $_SERVER['REDIRECT_UNIQUE_ID'];

for instance?

eak
08-27-2006, 01:29 AM
This works for me.


echo "<p>".$_SERVER['REDIRECT_URL']." was not found.</p>";

I have php5.1.2 on my home server.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum