【发布时间】:2013-05-08 12:01:28
【问题描述】:
我在 error.log 中收到这些消息:
Request URL: /files/thumbs1/1354046882.jpg
Stack Trace:
#0 /path/to/web/app/webroot/index.php(92): Dispatcher->dispatch(Object(CakeRequest), Object(CakeResponse))
#1 {main}
2013-05-08 13:44:16 Error: [MissingControllerException] Controller class FilesController could not be found.
Exception Attributes: array (
'class' => 'FilesController',
'plugin' => NULL,
)
图像文件 /files/thumbs1/1354046882.jpg 存在并显示。但除此之外,我在 error.log 中得到错误。 我在视图 .ctp 中手动生成 url,如下所示:
<img src="/files/thumbs1/1354046882.jpg" alt="">
我不使用 echo $this->Html->image('cake_logo.png', array('alt' => 'CakePHP'));
如何添加ControllerException,使webroot 中的“文件”目录不被识别为控制器。我没有 FilesController。 或者是否有可能,“文件”是 CakePHP 中不应使用的受保护词?目前在 CakeBook 中找不到相关的内容。
/webroot 中的 .htaccess
<IfModule mod_rewrite.c>
RewriteCond %{HTTP_HOST} !www.domainname.com
RewriteRule (.*) http://www.domainname.com/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
我更新到 CakePHP 2.3。 感谢您的帮助。
【问题讨论】:
-
你是如何产生这个错误的 url 的?你能用那个代码更新问题吗?
-
我用我如何生成文件的代码更新了这个问题。
-
你用的是原版
.htaccess吗?或者您是否对此进行了修改(例如将重写设置移动到虚拟主机)? -
我用 .htaccess 更新了问题。我在原来的基础上添加了一条重写规则,从 domain.com 变成 www.domain.com。我没有修改任何其他 .htaccess
-
@mart 哪里能解决问题?我对 webroot/uploads/ 目录有同样的问题。
标签: cakephp cakephp-2.3