Answer the question
In order to leave comments, you need to log in
How to correctly make a rule for UrlManager in Yii2?
There is a table of cities in b.d. in the format
city_id, city_name, city_slug
There are a lot of cities. I'm making a bulletin board. I want the following URL structure:
site.ru/city/category
i.e. the first parameter is city_slug.
Solved the issue like this:
'<city>/<category>/<page:\d+>' => 'main/index',
'<city>/<category>' => 'main/index',
'<city>' => 'main/index',
''=>'main/index',
<city:(moskva|spb|samara ... )>
Answer the question
In order to leave comments, you need to log in
Create your own rule class that will perform the logic you need and use it
Now the first parameter in the URL is always considered the city
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question