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

Categories as the first level subdirectory

Hello

I have some routes in my app including:

/login

/users

Now I also want my categories (e.g. programming, physics, biology, ...) use the first level subdirectories (our SEO person has requested this). I mean we can have

https://www.site.com/programming (to show list of programming discussions)

https://www.site.com/physics (to show list of physics discussions)

The problem is that if I define a route as following, even the login and users actions are forwarded to this route

/{category}

The order of route definition (i.e. the priority) is not considered. If it was considered, I could first define /login and /users and then /{category} at the end.

What can I do to solve this problem?



77.7k
Accepted
answer

Reverse the order in which you define your rules. By default, the router evaluates rules from bottom to top, in order of definition.



5.5k

Thank you very much. That solved the problem.