我正在开发Cakephp。在default.ctp中,我给出了一个像
这样的链接 <li><?= $this->Html->link('List',['controller' => 'Products', 'action' => 'index']) ?></li>
我还有一个ProductsController.php。
<?php
namespace App\Controller;
use Cake\Controller\Controller;
use Cake\Event\Event;
use Cake\ORM\TableRegistry;
class ProductsController extends AppController {
public function initialize(){
parent::initialize();
$this->loadcomponent('Flash');
}
public function index(){
$products = $this->Products->find('all');
$this->set(compact('products'));
}
但是当我点击该链接时,它会给出错误,如
单击切换参数时会显示
object(Cake\Network\Request) {
params => [
'plugin' => null,
'controller' => 'Webroot',
'action' => 'products',
'_ext' => null,
'pass' => [],
'_matchedRoute' => '/:controller/:action/*',
'isAjax' => false
]
data => []
query => []
cookies => [
'__atuvc' => '1|21'
]
url => 'webroot/products/'
base => '/cakephp'
webroot => '/cakephp/'
here => '/cakephp/webroot/products/'
trustProxy => false
请帮我解决这个错误。
答案 0 :(得分:0)
检查应用程序根文件夹和webroot文件夹中是否存在两个.htaccess文件。
并确保允许.htaccess覆盖,并且对于正确的DocumentRoot,AllowOverride设置为All
http://book.cakephp.org/3.0/en/installation.html#url-rewriting