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

Matching route that doesn't contain some word

How to do it ? Currently i have those routes in my application:

        $this->addGet('/poradnik/tag/{tagName}', array('action'=>'tag','controller'=>'index'));
        $this->addGet('/poradnik/{categoryName:(?<!\.tag)$}/{title}', array('action'=>'article','controller'=>'index')); // this doesn't work, 404

I had to do

$this->addGet('/poradnik/{categoryName}/{title}', array('action'=>'article','controller'=>'index'));

And check in action if categoryName is tag then forward to tag action. How to make working regex ?



145.0k
Accepted
answer

Well I just changed it to:

        $this->addGet('/poradnik/{categoryName}/{title}', array('action'=>'article','controller'=>'index'));
        $this->addGet('/poradnik/tag/{tagName}', array('action'=>'tag','controller'=>'index'));

And it's working. So obvious