Capturing File Not Found data

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Paddy
Forum Contributor
Posts: 244
Joined: Wed Jun 11, 2003 8:16 pm
Location: Hobart, Tas, Aussie
Contact:

Capturing File Not Found data

Post by Paddy »

Hey guys. I did search for this here but I could not find exactly what I needed.

When a user looks for a file that isn't there I would like for the 404.shtml file to redirect them to index.php. As well as redirect them I would also like to capture the URL they typed in so that I can process it at index.php for processing.

Any help would be greatly appreciated even if it is telling me it can't be done so I can stop looking. ;)
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

Either in httpd.conf or a .htaccess you could put
ErrorDocument 404 /index.php

Then in index.php

if (!empty($_SERVER['REDIRECT_STATUS']) && $_SERVER['REDIRECT_STATUS'] == 404){
//$_SERVER['REQUEST_URI'] is the page they originally requested
//do what you want with it here
}
Paddy
Forum Contributor
Posts: 244
Joined: Wed Jun 11, 2003 8:16 pm
Location: Hobart, Tas, Aussie
Contact:

Post by Paddy »

Having your children springs to mind.

Many thanks mate. :)
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

o_O

introducing mark, the php pimp.
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

:o
Post Reply