How to get which non-existend page led to error404.php

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

    How to get which non-existend page led to error404.php


    Hi,

    I have my error404.php page which includes
    these lines:

    echo "Document not found...";
    echo $_SERVER['REDIRECT_URL'];

    I also created a dummy link on another page, something
    like

    <a href=http://example.com/dummylinktogoto errorpage>dummy </a>

    When I click on the link I go to the error page
    however all I see is:

    Document not found.../error404.php

    But I expected to see what caused the error, so that I can
    record it to see if somebody is referring to some non-existent
    pages on my site.

    I used $_SERVER['REDIRECT_URL'] because of this O'Reilly
    article: http://www.onlamp.com/pub/a/onlamp/2...avidsklar.html

    Unfortunately either I miss something, or the article does not
    give correct info (or something's stragen with the configuration
    of the Apache at my hosting service).

    Any ideas? What should I check? Why $_SERVER['REDIRECT_URL'] hold
    the value "/error404.php"? How can I find the value
    I'm looking for?

    Thanks in advance.

    --
    Emre Sevinc

    eMBA Software Developer Actively engaged in:
    http:www.bilgi.edu.tr http://ileriseviye.org
    http://www.bilgi.edu.tr http://fazlamesai.net
    Cognitive Science Student http://cazci.com

  • Janwillem Borleffs

    #2
    Re: How to get which non-existend page led to error404.php

    Emre Sevinc wrote:[color=blue]
    > Any ideas? What should I check? Why $_SERVER['REDIRECT_URL'] hold
    > the value "/error404.php"? How can I find the value
    > I'm looking for?
    >[/color]

    $_SERVER['REQUEST_URI']


    JW




    Comment

    • Emre Sevinc

      #3
      Re: How to get which non-existend page led to error404.php

      "Janwillem Borleffs" <jw@jwscripts.c om> writes:
      [color=blue]
      > Emre Sevinc wrote:[color=green]
      >> Any ideas? What should I check? Why $_SERVER['REDIRECT_URL'] hold
      >> the value "/error404.php"? How can I find the value
      >> I'm looking for?
      >>[/color]
      >
      > $_SERVER['REQUEST_URI']
      >[/color]

      Modified the code:

      echo "Document not found...\n<br>" ;
      echo $_SERVER['REDIRECT_URL'] . "<br>";
      echo $_SERVER['REQUEST_URI'] . "<br>";

      Then clicked on a dummy linked on the same site to
      reach the error page but I get this output:

      Document not found...
      /error404.php
      /error404.php




      --
      Emre Sevinc

      eMBA Software Developer Actively engaged in:
      http:www.bilgi.edu.tr http://ileriseviye.org
      http://www.bilgi.edu.tr http://fazlamesai.net
      Cognitive Science Student http://cazci.com

      Comment

      • Janwillem Borleffs

        #4
        Re: How to get which non-existend page led to error404.php

        Emre Sevinc wrote:[color=blue]
        > Then clicked on a dummy linked on the same site to
        > reach the error page but I get this output:
        >
        > Document not found...
        > /error404.php
        > /error404.php[/color]

        Works for me with an .htaccess file with the ErrorDocument directive
        pointing to a PHP file in which $_SERVER['REQUEST_URI'] is printed.

        Check your server configuration or use the output of phpinfo() to examin the
        environmental variables.


        JW



        Comment

        • Emre Sevinc

          #5
          Re: How to get which non-existend page led to error404.php

          "Janwillem Borleffs" <jw@jwscripts.c om> writes:
          [color=blue]
          > Emre Sevinc wrote:[color=green]
          >> Then clicked on a dummy linked on the same site to
          >> reach the error page but I get this output:
          >>
          >> Document not found...
          >> /error404.php
          >> /error404.php[/color]
          >
          > Works for me with an .htaccess file with the ErrorDocument directive
          > pointing to a PHP file in which $_SERVER['REQUEST_URI'] is printed.
          >
          > Check your server configuration or use the output of phpinfo() to examin the
          > environmental variables.[/color]

          "echo"ing phpinfo() created an output like the one you can see
          at the end of my message.

          All I did was to use the web control panel of my hosting
          service, enter the addres of my error404.php as the error page
          and then enter the code that I described there and upload my newly
          created error404.php file there. No matter what I did I couldn't get
          the dummy link's name. Strange but that's what I have. Can it be something
          with the configuration?

          =============== =============== =============== =============== ============
          PHP Version 4.3.10

          System Linux linux01 2.4.24 #1 SMP Tue Aug 10 00:10:23 EEST 2004 i686

          Build Date Dec 22 2004 17:45:02

          Configure Command './configure'
          '--prefix=/sys/php-4.3.10-apache-1.3.33'
          '--with-apxs=/sys/apache-1.3.33/bin/apxs'
          '--with-mysql=/mysql/'
          '--with-curl=/sys/curl-7.11.1/'
          '--enable-ftp' '--enable-safe-mode'
          '--with-gd' '--with-xpm-dir' '--with-ttf'
          '--with-jpeg-dir' '--with-png-dir' '--enable-gd-native-ttf'
          '--with-freetype-dir=/usr/include/freetype2/' '--with-xpm'
          '--with-png-dir' '--with-zlib-dir'
          '--with-zlib' '--enable-calendar'
          '--with-gettext' '--enable-track-vars'
          '--with-config-file-path=/apache/conf/' '--enable-exif'
          '--enable-sockets' '--with-openssl'

          Server API Apache
          Virtual Directory Support disabled
          Configuration File (php.ini) Path /sys/apache_standart/conf/php.ini
          PHP API 20020918
          PHP Extension 20020429
          Zend Extension 20021010
          Debug Build no
          Thread Safety disabled
          Registered PHP Streams php, http, ftp, https, ftps, compress.zlib
          =============== =============== =============== =============== ===============


          --
          Emre Sevinc

          eMBA Software Developer Actively engaged in:
          http:www.bilgi.edu.tr http://ileriseviye.org
          http://www.bilgi.edu.tr http://fazlamesai.net
          Cognitive Science Student http://cazci.com

          Comment

          • Janwillem Borleffs

            #6
            Re: How to get which non-existend page led to error404.php

            Emre Sevinc wrote:[color=blue]
            > All I did was to use the web control panel of my hosting
            > service, enter the addres of my error404.php as the error page
            > and then enter the code that I described there and upload my newly
            > created error404.php file there. No matter what I did I couldn't get
            > the dummy link's name. Strange but that's what I have. Can it be
            > something with the configuration?
            >[/color]

            It sure has to do with the server configuration. Possibly, erroneous
            requests are redirected with a regular 301/302 response code, which would
            explain why you get the error page itself as the value of
            $_SERVER['REQUEST_URI']. Ask your provider for more info.


            JW



            Comment

            Working...