CodeIgniter Forums
Advanced 404 Handling? - Printable Version

+- CodeIgniter Forums (
+-- Forum: Archived Discussions (
+--- Forum: Archived Development & Programming (
+--- Thread: Advanced 404 Handling? (/thread-13262.html)

Advanced 404 Handling? - El Forum - 11-16-2008

Advanced 404 Handling?

I have a situation where I want to be able to create urls with random text where the controller class name is usually. For example, The random text would translate back to IDs I have stored into my database, where I would figure out what kind of an ID it is and redirect to the correct url. It's basically a convenience and url shortening approach.

At first, I thought I could use routes, but the text could be different lengths so I instead through extending the 404 handler in the exceptions class but that sounds messy. If there was only a pre_404 hook!

Has anyone done something similar and if so, any advice/guidance? Thanks.

Advanced 404 Handling? - El Forum - 11-16-2008

You can use regular expression syntax in the routes. Try using (.*)

Advanced 404 Handling? - El Forum - 11-16-2008

Thanks simonmaddox, I do realize that, but because of the length variations, it would have to be a wide open regex but then I would also need to add one for every actual controller I use which isn't as ideal. This is why I was thinking of just catching 404 errors and testing those.