We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Checking alternative route before proceeding

I was tasked with turning an old WP site into something proper, but some of those old links need 301s and they look like this: www.site.com/{brand} where {brand} is anything from Nutella to Renault.

Now, obviously this throws a wrench into my routing since I'm using the usual scheme of module/controller/action/params.

I'm wondering - is there a way to attach an event which would listen for such a route (www.site.com/oneWord), which would then be able to check if that brand exists and redirect to that brand's new link if so, or if not, it would simply make the app continue as usual, that is, it would go to /defaultModule/oneWordController?

I got it. The solution was in the beforeDispatchLoop event which triggers before the app even knows if the controller even exists - exactly what I needed. I could easily handle it from there.