D
D
djienbaev972019-12-25 13:25:43
Yii
djienbaev97, 2019-12-25 13:25:43

How to write in UrlManager rules?

5e033865dafdd621775382.png
I have such a link, here instead of city1=11 and city2=1 the name of the cities should come out, not the id of the city. I want to configure via urlmanager rules, but I don't know how, can you help?

'urlManager' => [
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            'rules' => [
                'o_nas'=>'site/about',

            ],
        ],

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim, 2019-12-27
@djienbaev97

Pass SLUG instead of ID. And you will be happy. And in URLManager regular expressions. Read about yii2 slug and you will understand how it's done. The task is typical and popular. For example How to implement slug in yii2?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question