I have catalogue with products. Urls for products looks like this domain.com/adv?id=14792
.
I want to beautify urls like this domain.com/adv/14792
.
In web.php I tried to like this
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'enableStrictParsing' => true,
'rules' => [
'adv/<id:d+>' => 'site/adv',
'<alias:[w-]+>' => 'site/<alias>',
],
],
and there is no result.
I tried another variant in rules block:
'rules' => [
'adv/<id:d+>' => 'adv',
'<alias:[w-]+>' => 'site/<alias>',
],
and urls start to look like I want. But on this link I get 404 page.
2
Answers
I solved my problem by myself. This is my urlmanager module now:
this construction build url from
https://example.com/adv?id=123456
tohttps://example.com/adv/123456
. In view link build withand in siteController action is
Thanx.
Please use action with adv so that it work.