M
M
Maxim Lagoysky2017-05-16 16:21:40
Yii
Maxim Lagoysky, 2017-05-16 16:21:40

Parsing and generating URLs, creating your own rules?

There are 2 links like this
test.com/site/category?id=1&cat=real-estate
test.com/site/sub?sub=9&al=premium
I want to get links like
test.com/real-estate?id=1&cat=real -estate
test.com/premium?sub=9&al=premium
But as far as I understand, the usual rules cannot be done here, since the controller is the same.
As I understand it, you need to write your own rule for parsing and generating url?
1) In what folder should it be created?
2) How to connect it correctly?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Timofeev, 2017-05-16
@webinar

the usual rules don't work here.

by no means:
'urlManager' => [
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            'rules' => [
              '/real-estate'=>'site/category',
              '/premium'=>'site/sub',
            ],
        ],

But it seems to me that test.com/site/premium/9 and test.com/real-estate/1 would be more beautiful

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question