Yii为什么这条路线不匹配

zujrkrfu  于 2022-11-09  发布在  其他
关注(0)|答案(1)|浏览(143)

我想为文章路由创建简单路由,但没有成功。我有第一个路由,它应该匹配正则表达式,第二个像鼻涕虫路由。第二个工作正常,但第一个不匹配什么。这个路由有什么问题?

'urlManager' => [
        'enablePrettyUrl' => true,
        'showScriptName' => false,
        'rules' => [
            'article/<action: (index|view|delete|create|update)>' => 'article/<action>',
            'article/<slug>' => 'article/view'
        ],
    ],
7lrncoxx

7lrncoxx1#

action:后面不应有空格:

'urlManager' => [
    'enablePrettyUrl' => true,
    'showScriptName' => false,
    'rules' => [
        'article/<action:(index|view|delete|create|update)>' => 'article/<action>',
        'article/<slug>' => 'article/view'
    ],
],

相关问题