I can't seem to get pretty urls to be generated properly. My frontend config is as follows:
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'rules' => [
'item/<id:\d+>/<slug>' => 'item/view',
'category/<id:\d+>/<slug>' => 'category/view',
'<controller:\w+>/<id:\d+>' => '<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
'<controller:\w+>/<action:\w+>' => '<controller>/<action>',
]
],
The following url array:
['item/view', 'id' => 4, 'slug' => 'shark-chomp-socks']
generates the url http://example.com/item/4?slug=shark-chomp-socks
instead of http://example.com/item/4/shark-chomp-socks
.
If I manually type in the expected url (http://example.com/item/4/shark-chomp-socks
), the url resolves correctly without any errors.
How can I get it to generate the url properly?