【发布时间】:2013-03-01 08:47:18
【问题描述】:
我一直在查看有关修复 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')
);
}
?>
一个带有方法的Controller 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 根目录、app 根目录、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”时,我都会得到:
有人对我缺少什么有任何想法吗? 我今天在一台新笔记本电脑上,而这是在我的上一台笔记本电脑上工作的。我必须错过一些东西......
【问题讨论】:
-
您是否按照book.cakephp.org/1.3/en/The-Manual/Developing-with-CakePHP/… 中的说明设置了
AllowOverride All? -
是的。我的默认目录是这样设置的:
Options FollowSymLinks AllowOverride All Options +MultiViews #Order deny,allow #Deny from all 另外,'apachectl configtest' 返回“Syntax OK”。
标签: cakephp mod-rewrite configuration http-status-code-404