RBAC 路由将模块的默认路由添加到项目的所有路由



如果我将cms模块的这个配置添加到配置文件中

'cms' => [
        'class' => 'yii2modcmsModule',
        'controllerNamespace' => 'backendcontrollers',
        'defaultRoute' => '',
        'froalaEditorOptions' => [
            'clientOptions' => [
                'heightMin' => 300,
                'theme' => 'dark',
                'imageUploadURL' => 'upload-image',
                'imageManagerDeleteURL' => 'delete-image',
                'imageManagerDeleteMethod' => 'POST',
                'imageManagerLoadURL' => 'images'
            ],
            'excludedPlugins' => [
                'file',
                'emoticons'
            ]
        ],
        'enableMarkdown' => false
]

它将此模块的默认路由添加到所有路由中,如下所示 /cms/site/login /cms/site/index /cms/site/error .为什么会发生这种情况以及如何删除它?

如果要默认删除/cms 模块前缀,可以添加全局路由到 backend/config/main.php(如果使用高级模板):'<controller:[w-]+>/<action:[w-]+>' =>'cms/<controller>/<action>' .

例如:

// backend/config/main.php
return [
    'urlManager' => [
        'enablePrettyUrl' => true,
        'showScriptName' => false,
        'rules' => [
            '<controller:[w-]+>/<action:[w-]+>' =>'cms/<controller>/<action>'
        ],
    ],
];

在您的 bowser: www.xxx.com/site/index 中访问,它被转发到: /cms/site/index

最新更新