2013-02-27 98 views
0

我一直在看帖子和一些Google Groups的東西來修復mod_rewrite與CakePHP(以及CakePHP文檔)一起使用,但我似乎無法讓mod_rewrite正常工作。mod_rewrite 404錯誤

CakePHP的安裝正常,我讓主網頁,我得到:enter image description here 然後創建了一個模型應用/型號/ Format.php:

<?php 

    /** 
    * File: app/Model/Format.php 
    * 
    * Format Model 
    */ 
    class Format extends AppModel 
    { 
     var $name = 'Format'; 

     // <hasMany> 
     var $hasMany = array(
           'DVD' => array('className' => 'DVD') 
          ); 
    } 

    ?> 

一個控制器應用程序/控制器/ FormatsController.php用方法:

function index() 
    {   // Ignore Format -related- data 
     $this->Format->recursive = 0; 

     // Get all formats from the database that have a status of '1' 
     $formats = $this->Format->find('all', array(
                 'conditions' => array('Format.status' => '1') 
                )); 

     // Save the Formats in a variable for display from the View 
     $this->set('formats', $formats); 
    } 

和最後一個視圖的應用程序/視圖/格式/ index.ctp:

<?php 
    // File: app/Views/Formats/index.ctp 
?> 

<div class='formats index'> 

    <table> 
     <thead> 
      <tr> 
       <th> Format Name</th> 
       <th> Description </th> 
       <th> Actions </th> 
      </tr> 
     </thead> 
     <tbody> 
      <?php 

      ?> 
     </tbody> 
    </table> 

</div> 

我的.htaccess文件位於cakephp根目錄,應用程序根目錄,webroot目錄均匹配CakePHP建議@http://book.cakephp.org/1.3/en/The-Manual/Developing-with-CakePHP/Installation.html

我還在每個這些.htaccess文件中添加了RewriteBase [我的應用程序目錄的路徑],因爲Google羣組中有人說他們爲他們工作。

但是,每當我嘗試加載 「cakecms /格式/指數」,我得到:

enter image description here

任何人有我缺少什麼,我什麼想法? 今天我在一臺新的筆記本電腦上,而這個所有的工作都在我最後一臺筆記本上。我必須錯過一些東西......

+0

您是否按照http://book.cakephp.org/1.3/en/The-Manual/Developing-with-CakePHP/Installation.html#apache-and-mod-rewrite-中的描述設置了「AllowOverride All」 -htaccess? – dhofstet 2013-02-27 05:53:02

+0

是的。 我的默認目錄是設置這樣的: 有FollowSymLinks 設置AllowOverride所有 選項+多視圖 #Order否認,允許所有 此外 #Deny '的apachectl configtest' 返回 「語法OK」。 – 2013-02-27 18:54:02

回答

0

[解決]

終於想通了,這是什麼,我失蹤了。 我從來沒有在我的httpd.conf文件更改默認

<Directory [DocumentRoot] /> 
.... 
</Directory> 

目錄。

雖然我在更具體的<Directory...>列表中允許覆蓋,但我拒絕他們在我的默認DocumentRoot之一。 一旦我在httpd.conf中的默認DocRoot目錄中更改爲AllowOverride All,Cake/Apache URL路由完美地工作。

0

如果你有一個URL重寫問題,你通常會在默認主頁上得到一個錯誤信息,你不這樣做可能不是問題。你應該檢查的網址是cakecms/formats(注意小寫字母「f」)。索引操作的「索引」部分是可選的。

+0

還要確保您的應用程序/配置/核心已打開調試。php – ADmad 2013-02-27 12:27:53

+0

cakecms /格式返回與上面截圖相同的頁面和錯誤。 我目前的調試級別設置爲2,但我仍然只是「未找到」。 我從來沒有使用過CakePHP的DebugKit;我想我會安裝它,看看它是否提供了新的見解。 – 2013-02-27 18:56:59