473,322 Members | 1,408 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

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 2651
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Shelly | last post by:
hi, I am trying to create a custom HTTP header and trying to access that variable on another ASP.NET webpage. Following is the code base- I use the following code to set the header...
6
by: John Lau | last post by:
Hi, I am looking at the MS KB Article 306355: HOW TO: Create Custom Error Reporting Pages in ASP.NET by Using Visual C# .NET This article describes how to redirect errors to a custom html...
6
by: Nick Horrocks | last post by:
I have set up a custom error page for 404 errors. However the HTTP status code returned is 302 followed by 200, this causes search engines not to remove old pages from their index. How can I...
1
by: Mukund Patel | last post by:
Hi friends, I have implemented custom error handling at page level and application level. If there is any syntax error in my aspx class file it will redirect to error page when I run the page....
7
by: Joe Rigley | last post by:
Hi, I have a custom class with a public method. I want to perform a repose.redirect if an error occurs in the public method GetUserRoles. Unfortunately, Visual Studio 2003 is throwing an error...
6
by: dee | last post by:
Hi In web.config I have to the following: <configuration> <system.web> <customErrors defaultRedirect="error.htm" mode="On" /> </system.web> </configuration>
8
by: bryan | last post by:
I've got a custom HttpHandler to process all requests for a given extension. It gets invoked OK, but if I try to do a Server.Transfer I get an HttpException. A Response.Redirect works, but I really...
0
by: gilly3 | last post by:
I'm coming across all kinds of frustration implementing custom errors in ASP.NET 1.1. First, 401 - Authorization Failed My application uses Windows Integrated Authentication, and restricts...
1
by: Jakob Lithner | last post by:
When I started a new ASP project I was eager to use the login facilities offered in Framework 2.0/VS 2005. I wanted: - A custom principal that could hold my integer UserID from the database -...
9
by: Nick | last post by:
Hi there, I would like to perform something like the following from my vb.net web service, being invoked via HTTP Post Call HttpContext.Current.Response.Redirect("myprotocol://myurl") ...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.