Yii2 - problem with url slugs..

Hi all,

so I have pages and categories and articles. Categories are connected with articles.

Pages have option to make a page tree.

So what I want to do is to make urls like:

pages:

example.com/portfolio/best-portfolio-of-all-time

categories with articles:

example.com/articles/

example.com/articles/best-article-of-all-time

Im doing this configuration, but Im getting 404 for category and articles…




        'urlManager' => [

            'enablePrettyUrl' => true,

            'showScriptName' => false,

            'enableStrictParsing' => false,

            'suffix' => '/',

            'rules' => [

                [

                    'pattern' => '<page_seo:[a-zA-Z0-9-]+>/<page_seo_second:[a-zA-Z0-9-]+>/',

                    'route' => 'pages/view',

                    'defaults' => [

                        'page_seo_second' => ''

                    ]

                ],

                '<cat:[a-zA-Z0-9-]+>/<article_seo:[a-zA-Z0-9-]+>' => 'articles/view',

                '<cat_seo:[a-zA-Z0-9-]+>/' => 'cats/view',

                

                '<controller:\w+>/<action:\w+>/<id:\d+>/*' => '<controller>/<action>/',

                '<controller:\w+>/<id:\d+>' => '<controller>/view',

                '<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',

                '<controller:\w+>/<action:\w+>' => '<controller>/<action>',


            ]

        ],



Does someone have the answer or idea whats wrong??

thanks

Move the rules of articles && categories above pages?