Yii2 url routing to get string parameter
I have a url like this
http: // localhost / yii2 / category / my-custom-string-parameter
I need to get the text my-custom-string-parameter
And I set up rules like this
'urlManager' => [
'class' => 'yii\web\UrlManager',
'showScriptName' => false,
'enablePrettyUrl' => true,
'rules' => array(
'<controller:\w+>/<id:\d+>' => '<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
'<controller:\w+>/<action:\w+>' => '<controller>/<action>',
'category/<url:>' => 'category/view',
),
],
It always gives me a 404 error. What should I do?
+3
source to share