将cakePHP 2.3.4 REST API从开发转移到生产404错误

将cakePHP 2.3.4 REST API从开发转移到生产404错误,cakephp,mod-rewrite,Cakephp,Mod Rewrite,我正在开发一个简单的RESTAPI,它正在开发我的开发系统(MacOSX、ZendStudio、ZendServerCE-http://localhost:10088/apitest/)在.htaccess文件中使用RewriteBase(见下文)。我修改了.htaccess文件以使用我创建的Apache 2.2虚拟主机(https://api.domain.com/)我收到了404个错误。唯一的更改是(1)重写url中的.htaccess、https:access中的基线 错误响应: <

我正在开发一个简单的RESTAPI,它正在开发我的开发系统(MacOSX、ZendStudio、ZendServerCE-
http://localhost:10088/apitest/
)在.htaccess文件中使用RewriteBase(见下文)。我修改了.htaccess文件以使用我创建的Apache 2.2虚拟主机(
https://api.domain.com/
)我收到了404个错误。唯一的更改是(1)重写url中的.htaccess、https:access中的基线

错误响应:

<response>
    <code>404</code>
    <url>/v1/flightlogs/9230.xml</url>
    <name>
        Controller class FlightlogsController could not be found.
    </name>
</response>
**下面的基线正在开发中**

/v1/.htaccess:

<IfModule mod_rewrite.c>
   RewriteEngine on
   #RewriteBase    /apitest/v1/
   RewriteBase    /v1/
   RewriteRule    ^$ app/webroot/    [L]
   RewriteRule    (.*) app/webroot/$1 [L]
</IfModule>
<IfModule mod_rewrite.c>
    RewriteEngine on
    #RewriteBase    /apitest/v1/app/
    RewriteBase    /v1/app/
    RewriteRule    ^$    webroot/    [L]
    RewriteRule    (.*) webroot/$1    [L]
</IfModule>
<IfModule mod_rewrite.c>
    RewriteEngine On
    #RewriteBase /apitest/v1/app/webroot/
    RewriteBase /v1/app/webroot/
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
我可以统计最终路径:/home/level/public_html/api/v1/app/webroot/index.php

[root@l4 httpd]# stat /home/level/public_html/api/v1/app/webroot/index.php
  File: `/home/level/public_html/api/v1/app/webroot/index.php'
  Size: 3189        Blocks: 8          IO Block: 4096   regular file
Device: fd00h/64768d    Inode: 2620573     Links: 1
Access: (0644/-rw-r--r--)  Uid: (  501/   level)   Gid: (  506/tracking)
Apache 2虚拟主机:

<VirtualHost *:443>
    ServerAdmin webmaster@airlinecert.com
    DocumentRoot /home/level/public_html/api
    ServerName api.levelflight.com:443
    ErrorLog logs/api_ssl_error_log
    TransferLog logs/api_ssl_access_log
    LogLevel warn
    RewriteEngine On
    RewriteOptions Inherit
    RewriteLog logs/api_rewritelog_log
    RewriteLogLevel 2

    <Directory "/home/level/public_html/api">
        Options -Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>


</VirtualHost>
Apache错误日志:

[Mon May 13 06:20:56 2013] [error] [client x.x.x.x] core.php:SetDebug:Server_Name: api.levelflight.com debug:2
url的区别是:

开发:
http://localhost:10088/apitest/v1/flightlogs/9230.xml

生产:
https://api.domain.com/v1/flightlogs/9230.xml

应该有什么东西打在我脸上,我看不见。有什么想法吗

/v1/app/tmp/logs/error.log

2013-05-13 06:05:38 Error: [MissingControllerException] Controller class FlightlogsController could not be found.
Exception Attributes: array (
  'class' => 'FlightlogsController',
  'plugin' => NULL,
)
Request URL: /v1/flightlogs/9230.xml
Stack Trace:
#0 /home/level/public_html/api/v1/app/webroot/index.php(109): Dispatcher->dispatch(Object(CakeRequest), Object(CakeResponse))
#1 {main}

~看起来像是区分大小写的问题。Mac OSX(不区分大小写)和Red Hat(区分大小写)之间的差异。飞行日志控制器和模型不一致:
FlightLogs
FlightLogs

我找到了
Flightlogs
的所有实例,并将它们更改为
Flightlogs
,错误似乎消失了


…l和l之间的区别…

显然,CakePHP正在工作,否则您将无法得到XML格式的响应。您可以尝试清除CakePHP缓存目录
app/tmp/cache/persistent/
app/tmp/cache/models/
app/tmp/cache/views/
。另外,确保apache能够写入
app/tmp
目录以及其中的任何内容。apache日志给了你什么吗?还要检查CakePHP日志文件
app/tmp/logs/*.log
?@thaJeztah:我已经清除了缓存,并在问题中添加了cakePHP错误日志和apache访问日志。新文件已写入cache/persistent。error.log显示了error_log(),其中我根据服务器名称设置了调试值,访问日志显示了请求中的正确用户。我还可以生成JSON格式的错误返回:)我还需要从
router::mapResources('flightlogs')对路由器进行更改
路由器::mapResources('flight_logs')
[Mon May 13 06:20:56 2013] [error] [client x.x.x.x] core.php:SetDebug:Server_Name: api.levelflight.com debug:2
2013-05-13 06:05:38 Error: [MissingControllerException] Controller class FlightlogsController could not be found.
Exception Attributes: array (
  'class' => 'FlightlogsController',
  'plugin' => NULL,
)
Request URL: /v1/flightlogs/9230.xml
Stack Trace:
#0 /home/level/public_html/api/v1/app/webroot/index.php(109): Dispatcher->dispatch(Object(CakeRequest), Object(CakeResponse))
#1 {main}