【发布时间】:2017-09-08 14:32:55
【问题描述】:
我正在开发一个 CakePHP 2.1 项目,但我遇到了关于管理面板“主页”的问题。
当我进入:mysite.com/admin 我有一条消息告诉我“找不到 AdminController”。
我在 config/routes.php 中声明了这条路线:
Router::connect('/admin', array('controller' => 'mycontroller', 'action' => 'index', 'admin' => true));
当我输入 mysite.com/admin/mycontroller 作为 URI 时,它可以工作。 你有什么想法吗?
提前谢谢你。
编辑 |我的 routes.php 文件:`
/**
* Here, we are connecting '/' (base path) to controller called 'Pages',
* its action called 'display', and we pass a param to select the view file
* to use (in this case, /app/View/Pages/home.ctp)...
*/
Router::connect('/', array('controller' => 'pages', 'action' => 'display', 'home'));
/**
* ...and connect the rest of 'Pages' controller's URLs.
*/
Router::connect('/pages/*', array('controller' => 'pages', 'action' => 'display'));
/**
* Load all plugin routes. See the CakePlugin documentation on
* how to customize the loading of plugin routes.
*/
CakePlugin::routes();
/**
* Load the CakePHP default routes. Only remove this if you do not want to use
* the built-in default routes.
*/
require CAKE . 'Config' . DS . 'routes.php';
// Custom routes
Router::connect('/admin', array('controller' => 'jobapplications', 'action' => 'index', 'admin' => true));
【问题讨论】:
-
可能定义了更多的路由,即可能存在冲突的路由。
-
我用 routes.php 的内容编辑了我的帖子。
标签: cakephp routes cakephp-2.1