We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

Phalcon two single routes

I have a problem. I have two routes:

$router->add('/news/{alias:[a-z\-]+}(/?)', array(
      'module' => 'frontend',
      'controller' => 'news',
      'action' => 'view',
      'news_id' => 1,
      'lang' => 'md',
))->setName('news_view_short_e'); //=> /news/282334-alias-news

AND route => /news/index/:

$router->add('/{lang:[' . $langsDefined . ']{2}+}/{controller:[a-z]{3,50}+}(/?)', array(
     'module' => 'frontend',
     'controller' => 2,
     'action' => 'index',
     'lang' => 1,

When I use these routes. site.com/news/index not working. But if I remove route with alias. Route site.com/news/index working good. How I can resolve conflict?

edited Dec '17

Obviously this second one overrides the first one, i guess you need to add them in reversed order you are adding them now.

edited Dec '17

What does your $langsDefined variable look like?

{lang:[' . $langsDefined . ']{2}+} this should limit the match to two characters, so news shouldnt be matched

Oh yea that's true.