gpt4 book ai didi

php - 隐藏 url 中的所有 Controller

转载 作者:可可西里 更新时间:2023-10-31 22:57:39 24 4
gpt4 key购买 nike

我使用 Yii 的 urlManager 将我的 url 从 mypage.com/controller/view 重写为 mypage.com/view。但是我有不止一个 Controller 并且想在所有 Controller 上应用它。这能做到吗?

我当前的 urlManager:

'urlManager'=>array(
'urlFormat'=>'path',
'showScriptName'=>false,
'rules'=>array(
'<action:\w+>' => 'site/<action>',
),
),

最佳答案

第一种方式:

'<action:(login|logout|about)>' => 'site/<action>',
'<action:(view|edit)>' => 'product/<action>',

实现此功能的第二种方法是使用 Using Custom URL Rule Classes

关于php - 隐藏 url 中的所有 Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10237979/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com