Error 404 enigma

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Adam

    Error 404 enigma

    I'm having a problem with finding the URL error value with a custom
    error404 (PHP) page - accessed via an .htaccess error redirect.

    Let's say I have a link in "test.php" to "wups.php" in a document -
    and "wups.php" no longer exists (and I forgot to amend the link in
    "test.php") .

    Is it possible to retrieve the [erroneous] link info?

    All I seem to be able to get is the referring page (test.php) and the
    actual error page (error.php) that the user gets redirected to.

    Adam.
  • Colin McKinnon

    #2
    Re: Error 404 enigma

    Adam wrote:
    [color=blue]
    > I'm having a problem with finding the URL error value with a custom
    > error404 (PHP) page - accessed via an .htaccess error redirect.
    >[/color]

    try putting print_r($_SERVE R) in your errorpage - it may give you a clue.

    C.

    Comment

    • Adam

      #3
      Re: Error 404 enigma

      On Fri, 16 Jun 2006 19:21:39 GMT, Colin McKinnon wrote:
      [color=blue]
      >Adam wrote:
      >[color=green]
      >> I'm having a problem with finding the URL error value with a custom
      >> error404 (PHP) page - accessed via an .htaccess error redirect.
      >>[/color]
      >
      >try putting print_r($_SERVE R) in your errorpage - it may give you a clue.[/color]

      Thanks - but no joy :-(

      The array spits out the expected variables - but anything related to
      URLs (REFERER, SCRIPT_NAME, URI etc.) all point either to the
      referring page or the final error page. Nothing contains the failed
      URL information.

      I'll check the Apache logs to see whether anything gets written there,
      but I'm really trying to find a solution that doesn't involve messing
      with logs.

      Basically, it appears then that if I have a "totally_non_ex istant.php"
      link in a page, a user [rightly] gets the custom error page but
      there's no way I can work out what the bad link is - other than that
      it's somewhere on that referring page <??>.

      Adam.

      Comment

      • Adam

        #4
        Re: Error 404 enigma

        On Fri, 16 Jun 2006 19:21:39 GMT, Colin McKinnon wrote:
        [color=blue]
        >Adam wrote:
        >[color=green]
        >> I'm having a problem with finding the URL error value with a custom
        >> error404 (PHP) page - accessed via an .htaccess error redirect.
        >>[/color]
        >
        >try putting print_r($_SERVE R) in your errorpage - it may give you a clue.[/color]

        To follow up - yes - it *does* get written to Apache's error.log -
        with a "script not found or unable to stat" error plus the referring
        URL..

        There must be a way to trap this in PHP, Shirley?

        Adam.

        Comment

        • Adam

          #5
          Re: Error 404 enigma

          On Sun, 18 Jun 2006 13:11:49 +1200, Adam wrote:
          [color=blue]
          >There must be a way to trap this in PHP, Shirley?[/color]

          To answer my own post (sure sign of madness!):



          If your ErrorDocument startswith http:// Apache sends a redirect (302)
          to the error document, hence ***losing your original referer***. If
          your ErrorDocument points to a relative path, 404 is maintained and so
          are your variables.

          I was using "http://" in my .htaccess - so $_SERVER['REQUEST_URI'] was
          giving me the wrong value.

          Using *relative* paths in .htaccess cured the problem - I now get a
          full error URL passed to my error.php ... YAY!

          Adam.

          Comment

          Working...