我有一个这样的网址
http:// localhost / yii2 / category / my-custom-string-parameter
我需要获取文本my-custom-string-parameter
我设置了这样的规则
'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',
),
],
这总是给我404错误。我应该怎么办?
替换'category/<url:>' => 'category/view',,
为'category/<id:\w+>' => 'category/view'
路由到View需要一个id并使用w +而不是url来使用字符串:
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句