V
V
Vladislav2020-02-14 16:44:22
Yii
Vladislav, 2020-02-14 16:44:22

How to do CNC with Yii regex?

There is a link like site.ru/news?id=2 It is
necessary to make it look like this site.ru/news/2/
I wrote in the rules but it doesn’t work for me If you need the whole manager'<action>/<\d+>/'=>'site/news?id=\d+',

'urlManager' => [
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            'rules' => [
                '<action>/<\d+>/'=>'site/news?id=<\d+>',
                 '<action>' => 'site/<action>',
            ],
        ],

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladislav, 2020-02-15
@cr1gger

'urlManager' => [
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            'rules' => [
                [
                    'pattern' => 'news/<id:\d+>',
                    'route' => 'site/news',
                    'suffix' => '/'
                ],
                '<action>'=>'site/<action>',
                
            ],
        ],

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question