路由和URL创建- Yii框架

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

我的Web应用程序中有一个URL:

https://domain/store/cuisine?category=33

我想创建一个路由到:

https://domain/destiny to https://domain/cuisine?category=33

我又道:

'edobhi' => 'store/cuisine?category=33',

404错误提示404错误提示
我该如何发送此邮件?

jtw3ybtb

jtw3ybtb1#

查看此处https://www.yiiframework.com/doc/guide/2.0/en/runtime-routing#default-parameter-values
因此,您的规则看起来会像这样:

'rules' => [
    // ...other rules...
    [
        'pattern' => 'edobhi',
        'route' => 'store/cuisine',
        'defaults' => ['category' => 33],
    ],
]

现在,您可以使用参数$category=33访问将Map到StoreControllerhttps://domain/edobhi和操作actionCuisine

相关问题