Advanced 404 Handling? |
[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.
[eluser]simonmaddox[/eluser]
You can use regular expression syntax in the routes. Try using (.*)
[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. |
Welcome Guest, Not a member yet? Register Sign In |