Page 1 of 1
PHP To catch incorrect URL
Posted: Wed Jul 13, 2005 6:09 am
by mswansonpcs
Hello,
We made a major structure change to our web site. Our server allows us to create custom error pages instead of the standard 404 page not found, etc. Anyway, is it possible to create some sort of PHP (or other language) page that can capture the incorrect URL. If so, I could check it agains a database and redirect the user to the new page. Is this even possible?
Thanks
mswansonpcs
Posted: Wed Jul 13, 2005 7:39 am
by Chris Corbyn
Check what against the database? What would you be checking?
You mean like try to work out where they were going? mod_rewrite could handle that for you

Hmm.
Posted: Wed Jul 13, 2005 7:49 am
by mswansonpcs
Interesting, I've been reading about this but i'm not sure its what i'm looking for.
What I have is a huge site, which before the changes was approx 2500 html pages. I have made several changes using php and database connectivity to reduce these pages. What i essentially want to do is this:
A user goes to mysite.com/123/ghda/dhfd/dfj/sjj/djf/index.htm
The page does not exist so instead of a 404 not found, a custom php page is shown.
The php page takes the requested URL, connects to a lookup table in the database. If the page used to exist, then it is bounced to the new location. If not, a simple error message is shown.
What i don't know how to do is capture that URL that was originally intended short of leaving empty redirect pages in every location where a page used to exist...
Does this make it any more clear, thanks...
Posted: Wed Jul 13, 2005 7:51 am
by shiznatix
that makes plenty of sence. you can definatly make a custom 404 error page with whatever you want in it and maybe use http_reffer to get the url? maybe but probebly not but its worth a look atleast
Posted: Wed Jul 13, 2005 8:37 am
by theda
I have a similar thing, but it doesn't run on databases... It's pretty much conditionals to check if the file exists on my server, and if not, it reloads back to the index page (or if I wanted, a 404 page..)