我一直在查看用于修复 mod_rewrite 以用于 CakePHP(以及 CakePHP 文档)的帖子和一些 Google Groups 资料,但我似乎无法让 mod_rewrite 正常工作。
CakePHP 安装得很好,我得到了主页,我得到:
然后我创建了一个模型 app/Model/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')
);
}
?>
带有方法的控制器 app/Controller/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);
}
最后是 View app/View/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>
我在 cakephp 根目录、应用程序根目录、webroot 目录中的 .htaccess 文件都符合 CakePHP 建议 @ http://book.cakephp.org/1.3/en/The-Manual/Developing-with-CakePHP/Installation.html。
我还将 RewriteBase [path to my app dir] 添加到每个 .htaccess 文件中,因为 Google 小组中的某个人说它对他们有用。
但是,每当我尝试加载“cakecms/Formats/index”时,我都会得到:
有人对我缺少的东西有任何想法吗?我今天在一台新笔记本电脑上,这一切都在我的最后一台上工作。我必须错过一些东西......