0

我想用我的网址管理器链接那个。关于我的博客详细信息

http://example.com/yii-fremwork-install => 转到博客控制器详细信息方法

其中“yii-fremwork-install”是来自数据库的slug。

我也不会为此编写我的 url 管理器的模块

'rules' => array(
                '<slug:.+>' => 'users/details',
                '<controller:\w+>/<id:\d+>' => '<controller>/view',
                '<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
                '<controller:\w+>/<action:\w+>' => '<controller>/<action>',

            ),

但是当我想使用我的管理模块时

http://example.com/admin 它去用户/详细信息控制器锄头使用这个

有人可以提出一些想法来解决这个问题。

4

1 回答 1

0

这里的问题<slug:.+>是用于每条路线。

您必须在规则数组中手动​​定义所有控制器并首先定义它们

像这样 :

'rules' => array(
            '<controller:admin|default|item>' => '<controller>',
            '<controller:admin|default|item>/<id:\d+>' => '<controller>/view',
            '<controller:admin|default|item>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
            '<controller:admin|default|item>/<action:\w+>' => '<controller>/<action>',
            '<slug:.+>' => 'users/details',
        ),

您的其他 3 个控制器在哪里(例如)AdminControllerDefaultController以及ItemController

于 2017-11-20T16:14:13.850 回答