Answer the question
In order to leave comments, you need to log in
How to setup urlManager for slugs?
Good afternoon. I'm trying to set up the urlManager so that it handles the slug, but I just can't write the rule.
When forming the url, I pass an additional slug parameter like this:
Url::to(['site/page', 'id' => $id, 'slug' => $slug]),
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'enableStrictParsing' => false,
'rules' => [
'/' => 'site/index',
'<action:\w+>/<id:\d+>/<slug:[a-z0-9_-]+>' => 'site/<action>/<slug>',
'<action:\w+>/<id:\d+>' => 'site/<action>',
'<action:\w+>' => 'site/<action>',
],
],
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question