473,387 Members | 1,365 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,387 software developers and data experts.

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.
Jun 16 '06 #1
4 1277
Adam wrote:
I'm having a problem with finding the URL error value with a custom
error404 (PHP) page - accessed via an .htaccess error redirect.


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

C.
Jun 16 '06 #2
On Fri, 16 Jun 2006 19:21:39 GMT, Colin McKinnon wrote:
Adam wrote:
I'm having a problem with finding the URL error value with a custom
error404 (PHP) page - accessed via an .htaccess error redirect.


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


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_existant.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.
Jun 18 '06 #3
On Fri, 16 Jun 2006 19:21:39 GMT, Colin McKinnon wrote:
Adam wrote:
I'm having a problem with finding the URL error value with a custom
error404 (PHP) page - accessed via an .htaccess error redirect.


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


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.
Jun 18 '06 #4
On Sun, 18 Jun 2006 13:11:49 +1200, Adam wrote:
There must be a way to trap this in PHP, Shirley?


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

http://httpd.apache.org/docs/2.1/mod...#errordocument

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.
Jun 18 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Sheldon | last post by:
Hi, I have a written a script that will check to see if the divisor is zero before executing but python will not allow this: if statistic_array > 0.0: statistic_array =...
5
by: Mike Currie | last post by:
Can anyone explain why I'm getting an ascii encoding error when I'm trying to write out using a UTF-8 encoder? Thanks Python 2.4.3 (#69, Mar 29 2006, 17:35:34) on win32 Type "help",...
4
by: David Bear | last post by:
I built python 2.4.2 for suse linux 9.3. I configured it to be a separate instance of python from the version packaged with suse. Now when I start it I get an error: python Python 2.4.2 (#4,...
1
by: Jia,Lu | last post by:
hello,all. I wrote a module in C as below, BUT msg() method cannot work allright. #include <stdio.h> #include <python2.4/Python.h> static PyObject *Roka_msg(PyObject *self,PyObject *args)...
13
by: Protoman | last post by:
I'm getting an error: 10 C:\Dev-Cpp\Enigma.cpp no match for 'operator<' in 'i < (+cleartext)->std::basic_string<_CharT, _Traits, _Alloc>::end ()' Code: Enigma.hpp...
5
by: Tyler | last post by:
Hello All: Since my last post I have attempted to use the f2py program which comes with numpy. I am able to create a <module_name>.so file fine; however, when I import it into Python, I receive...
4
by: Protoman | last post by:
Can you please help me figure out what the error is here, in this rotor cipher simulator, which I wrote to amuse myself? The runtime error is that it isn't symmetrical --decrypting a piece of...
4
by: Evelien | last post by:
Dear python-users, I am trying to do a non-linear least squares fitting. Maybe trying is not the best word, as I already succeeded in that. At the moment I am using leastSquaresFit from...
0
by: John [H2O] | last post by:
I can try, would you mind giving very brief instructions on how to 'run it under gdb'... thanks! I'll post results over at numpy-discussions. Robert Kern-2 wrote: -- View this message in...
3
by: Terry Reedy | last post by:
Stef Mientki wrote: You have gotten the 2.x answer. In 3.0, 0b,0o,0x prefixes are valid and required for binary, octal, and hexadecimal literals. 0digits is invalid. tjr
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

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.