【发布时间】:2010-09-01 01:59:48
【问题描述】:
(我真的希望我在发布之前对谷歌和搜索栏进行了足够的尽职调查)
我开始使用 CakePHP,刚刚创建了我的第一个模型、控制器和视图。
当我浏览到 http://localhost/~me/MyApp/Lists 时,我得到一个 404,但我不知道为什么
这是我的控制器
<?php
class ListsController extends AppController
{
var $name = 'Lists';
function index()
{
$this->set('lists', $this->List->find('all'));
}
}
?>
我认为这是一个 .htaccess 问题,但是当我浏览到 http://localhost/~me/MyApp/app 或 http://localhost/~me/MyApp/index 时,我得到一个“缺少控制器”错误页面。当然,这两个 URL 都会指向实际的文件或目录。
谁能告诉我为什么我的控制器会出现这个 404?
下面留下几个cmets的更新(见Leo的回答)
应用程序根目录的我的 .htacces
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
我的 CakePHP webroot 的 .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>
【问题讨论】:
-
丢失的控制器是否存在于 Missing Controller 消息中的确切位置和确切名称中?
标签: php cakephp http-status-code-404