469,903 Members | 1,506 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,903 developers. It's quick & easy.

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
Jul 17 '05 #1
2 2451
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" <sp****@virtualslo.com> wrote in message
news:a0**************************@posting.google.c om...
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

Jul 17 '05 #2
Sean Pinto wrote:
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.
And what status code is returned to the client? It should be 404 for a
not found page.
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" ?


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)
http://www.tsmchughs.com/
Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Shelly | last post: by
6 posts views Thread by John Lau | last post: by
6 posts views Thread by Nick Horrocks | last post: by
1 post views Thread by Mukund Patel | last post: by
7 posts views Thread by Joe Rigley | last post: by
6 posts views Thread by dee | last post: by
8 posts views Thread by bryan | last post: by
reply views Thread by gilly3 | last post: by
1 post views Thread by Jakob Lithner | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.