PHP To catch incorrect URL

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
mswansonpcs
Forum Newbie
Posts: 2
Joined: Wed Jul 13, 2005 6:05 am

PHP To catch incorrect URL

Post 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
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post 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 ;)
mswansonpcs
Forum Newbie
Posts: 2
Joined: Wed Jul 13, 2005 6:05 am

Hmm.

Post 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...
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post 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
theda
Forum Contributor
Posts: 332
Joined: Sat Feb 19, 2005 8:35 am
Location: USA

Post 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..)
Post Reply