Custom Redirect Page

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

    Custom Redirect Page

    My hosting company has an automatic redirect page called
    /missing/missing.php and I want to log all of the page not founds that
    result in a redirection to missing.php. I can't seem to find out how
    to get the string that the web user typed to get there. I have
    checked $_SERVER['REDIRECT_URI'] but it has /missing/missing.php and
    $_SERVER['HTTP_REFERER'] is empty. Does anyone know how to get
    "/abcdef" if the user navigated to "http://mydomain.com/abcdef" ? Any
    help is appreciated.

    Thanks,
    Sean
  • Ben Gribaudo

    #2
    Re: Custom Redirect Page

    Hi Sean,

    URL of the page that wasn't found:
    $_SERVER['REDIRECT_URL']

    Query string submitted to the page that wasn't found:
    $_SERVER['REDIRECT_QUERY _STRING']

    URL that referred the visitor to the page that wasn't found:
    $_SERVER['HTTP_REFERER']

    The above probably won't work if your site is configured to *redirect*
    requests for non-existent documents to the error page--that is, if it sends
    a redirect header to the browser pointing to /missing.php. When the user
    visits a "real" error page (vs. a redirected to on error page), they are not
    redirected--the error message is displayed at the bad URL. To configure
    things as such with Apache, insert:
    ErrorDocument 404 /scripts/not_found.php
    into .htaccess (assuming your server's config allows that directive in
    ..htaccess).

    Have a great day!

    Ben :-)
    Ben Gribaudo - Baltimore, MD - www.bengribaudo.com

    "For God so loved the world, that he gave his only begotten Son, that
    whosoever believeth in him should not perish, but have everlasting life."
    John 3:16


    "Sean Pinto" <spinto@virtual slo.com> wrote in message
    news:a0453bc1.0 407131337.51445 648@posting.goo gle.com...[color=blue]
    > My hosting company has an automatic redirect page called
    > /missing/missing.php and I want to log all of the page not founds that
    > result in a redirection to missing.php. I can't seem to find out how
    > to get the string that the web user typed to get there. I have
    > checked $_SERVER['REDIRECT_URI'] but it has /missing/missing.php and
    > $_SERVER['HTTP_REFERER'] is empty. Does anyone know how to get
    > "/abcdef" if the user navigated to "http://mydomain.com/abcdef" ? Any
    > help is appreciated.
    >
    > Thanks,
    > Sean[/color]


    Comment

    • Brian

      #3
      Re: Custom Redirect Page

      Sean Pinto wrote:
      [color=blue]
      > My hosting company has an automatic redirect page called
      > /missing/missing.php and I want to log all of the page not founds
      > that result in a redirection to missing.php.[/color]

      And what status code is returned to the client? It should be 404 for a
      not found page.
      [color=blue]
      > I can't seem to find out how to get the string that the web user
      > typed to get there. I have checked $_SERVER['REDIRECT_URI'] but it
      > has /missing/missing.php and $_SERVER['HTTP_REFERER'] is empty.
      > Does anyone know how to get "/abcdef" if the user navigated to
      > "http://mydomain.com/abcdef" ?[/color]

      Use the server's mechanism for a customized error document. For
      Apache, use

      ErrorDocument 404 //missing/missing.php

      That will provide users your php "missing" script and the correct 404
      status code.

      --
      Brian (remove ".invalid" to email me)

      Comment

      Working...