Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Sep 2005
    Posts
    31
    Thanks
    2
    Thanked 0 Times in 0 Posts

    HELP! 404 Error page with previous url displayed

    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/show...oto=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

  • #2
    eak
    eak is offline
    Regular Coder eak's Avatar
    Join Date
    Jun 2002
    Location
    Nashville, TN
    Posts
    354
    Thanks
    0
    Thanked 26 Times in 26 Posts
    try these other globals.
    PHP Code:
    $_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'
    eak | "Doing a good deed is like wetting your pants; every one can see the results, but only you can feel the warmth."

  • #3
    New Coder
    Join Date
    Sep 2005
    Posts
    31
    Thanks
    2
    Thanked 0 Times in 0 Posts
    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?

  • #4
    eak
    eak is offline
    Regular Coder eak's Avatar
    Join Date
    Jun 2002
    Location
    Nashville, TN
    Posts
    354
    Thanks
    0
    Thanked 26 Times in 26 Posts
    This works for me.

    PHP Code:
    echo "<p>".$_SERVER['REDIRECT_URL']." was not found.</p>"
    I have php5.1.2 on my home server.
    eak | "Doing a good deed is like wetting your pants; every one can see the results, but only you can feel the warmth."


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •