我一直在看帖子和一些Google Groups的東西來修復mod_rewrite與CakePHP(以及CakePHP文檔)一起使用,但我似乎無法讓mod_rewrite正常工作。mod_rewrite 404錯誤
CakePHP的安裝正常,我讓主網頁,我得到: 然後創建了一個模型應用/型號/ 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 /格式/指數」,我得到:
任何人有我缺少什麼,我什麼想法? 今天我在一臺新的筆記本電腦上,而這個是所有的工作都在我最後一臺筆記本上。我必須錯過一些東西......
您是否按照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
是的。 我的默認目錄是設置這樣的: 有FollowSymLinks 設置AllowOverride所有 選項+多視圖 #Order否認,允許所有 此外 #Deny '的apachectl configtest' 返回 「語法OK」。 –
2013-02-27 18:54:02