2016-07-01 85 views
0

我正在Cakephp上工作。在default.ctp我給鏈接像Cakephp進入錯誤路徑

<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')); 
} 

但是,當我是點擊它給像

  1. 錯誤的錯誤:WebrootController找不到。
  2. 錯誤:在文件中創建以下類WebrootController:SRC /控制器/ WebrootController.php

當點擊切換參數它顯示

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

檢查您的應用程序根文件夾和webroot文件夾中是否存在兩個.htaccess文件。

,並確保一個.htaccess覆蓋被允許,並且設置AllowOverride設置爲所有正確的DocumentRoot

http://book.cakephp.org/3.0/en/installation.html#url-rewriting

+0

是有兩個.htaccess文件都存在。一個是在webroot中,另一個是在我的項目文件夾中。@ Alex Stallen –

+0

您是否檢查內容是否與鏈接中的內容相同?並確保允許.htaccess覆蓋,並且爲正確的DocumentRoot設置AllowOverride爲All –