favicon.ico 不存在
默认情况下,CakePHP 中有以下路由:
/:controller
如果对不存在的文件发出请求,它将表现为缺少控制器错误。例如请求一个存在“正常工作”的文件:
$ pwd
/var/www/2.x/app/webroot
$ls
css favicon.ico files img index.php js test.php
$ curl -I http://cakephp.2.dev/favicon.ico
HTTP/1.1 200 OK
Date: Wed, 24 Jul 2013 11:25:07 GMT
Server: Apache/2.2.22 (Ubuntu)
Last-Modified: Wed, 24 Jul 2013 11:25:07 GMT
ETag: W/"1c7-174-4e2402c11f000"
Accept-Ranges: bytes
Content-Length: 372
Content-Type: image/x-icon
删除文件会导致 404:
$ rm favicon.ico
$ curl -I http://cakephp.2.dev/favicon.ico
HTTP/1.1 404 Not Found
Date: Wed, 24 Jul 2013 11:26:52 GMT
Server: Apache/2.2.22 (Ubuntu)
X-Powered-By: PHP/5.4.17RC1
Set-Cookie: CAKEPHP=0h68rnghqaku6d8eo30od1ga06; expires=Wed, 24-Jul-2013 15:26:53 GMT; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Content-Length: 2861
Vary: Accept-Encoding
Content-Type: text/html; charset=UTF-8
不出所料,但不仅如此,生成的错误消息是针对缺少的<file>
控制器:
$ curl -i http://cakephp.2.dev/favicon.ico
...
<em>Favicon.icoController</em> could not be found.</p>
因此 - 要获取问题中的错误消息 - 文件不存在(或由于文件权限而无法读取)。