CodeIgniter Forums
Advanced 404 Handling? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Advanced 404 Handling? (/showthread.php?tid=13262)



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

[eluser]dmorin[/eluser]
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, http://example.com/random_text. 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

[eluser]simonmaddox[/eluser]
You can use regular expression syntax in the routes. Try using (.*)


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

[eluser]dmorin[/eluser]
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.