我在app/plugins中添加了CakeDC-Users插件。
现在为http://example.com/ ,如果我单击 home/index 链接,它会错误地重定向到 http://example.com/users/posts/index ,但应该是http://example.com/posts/index .
为什么插件“users”总是添加在相应 Controller 之前?
如果我从 app/Plugin 中删除 CakeDC-Users 插件并从 bootstrap.php 中删除该行 CakePlugin::loadAll();
然后我会得到正常的链接/路由
routes.php:
Router::connect('/', array('controller' => 'posts', 'action' => 'index'));
我如何解决添加 CakeDC-Users 插件的问题
最佳答案
这就是访问插件的方式。您可以通过这种方式定义您的自定义路线
Router::connect('/posts', array('controller' => 'posts', 'plugin' => 'users'));
这将在 app/Config/routes.php 中完成
如果是链接问题,您必须明确指定
echo $this->Html->link('link', array(
'controller' => '',
'action' => '',
'plugin' => false)
);
但我更喜欢自定义路由。
如需了解更多信息,您可以随时进入CookBook
关于php - 添加插件后cakephp路由问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9866225/