0

我正在开发一个简单的 REST API,它正在我的开发系统(Mac OSX、Zend Studio、Zend Server CE - http://localhost:10088/apitest/)上使用 .htaccess 文件中的 RewriteBase(见下文)。我修改了 .htaccess 文件以使用我创建的 Apache 2.2 虚拟主机 ( https://api.domain.com/),我收到 404 错误。唯一的变化是 .htaccess 中的 (1) RewriteBase 行,https: url 中的访问。

错误响应:

<response>
    <code>404</code>
    <url>/v1/flightlogs/9230.xml</url>
    <name>
        Controller class FlightlogsController could not be found.
    </name>
</response>

** 下面注释的 RewriteBase 行正在开发中。**

/v1/.htaccess:

<IfModule mod_rewrite.c>
   RewriteEngine on
   #RewriteBase    /apitest/v1/
   RewriteBase    /v1/
   RewriteRule    ^$ app/webroot/    [L]
   RewriteRule    (.*) app/webroot/$1 [L]
</IfModule>

/v1/app/.htaccess:

<IfModule mod_rewrite.c>
    RewriteEngine on
    #RewriteBase    /apitest/v1/app/
    RewriteBase    /v1/app/
    RewriteRule    ^$    webroot/    [L]
    RewriteRule    (.*) webroot/$1    [L]
</IfModule>

/v1/app/webroot/.htaccess:

<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>

Apache重写日志:

[api.domain.com] (2) [perdir /home/level/public_html/api/v1/] trying to replace prefix /home/level/public_html/api/v1/ with /v1/
[api.domain.com] (2) init rewrite engine with requested uri /v1/app/webroot/flightlogs/9230.xml
[api.domain.com] (1) pass through /v1/app/webroot/flightlogs/9230.xml
[api.domain.com] (2) [perdir /home/level/public_html/api/v1/app/webroot/] rewrite 'flightlogs/9230.xml' -> 'index.php'
[api.domain.com] (2) [perdir /home/level/public_html/api/v1/app/webroot/] trying to replace prefix /home/level/public_html/api/v1/app/webroot/ with /v1/app/webroot/
[api.domain.com] (1) [perdir /home/level/public_html/api/v1/app/webroot/] internal redirect with /v1/app/webroot/index.php [INTERNAL REDIRECT]
[api.domain.com] (2) init rewrite engine with requested uri /v1/app/webroot/index.php
[api.domain.com] (1) pass through /v1/app/webroot/index.php
[api.domain.com] (1) [perdir /home/level/public_html/api/v1/app/webroot/] pass through /home/level/public_html/api/v1/app/webroot/index.php

我可以统计最终路径:/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>

阿帕奇访问日志:

173.60.78.93 - api_username [13/May/2013:06:20:56 -0700] "GET /v1/flightlogs/9230.xml HTTP/1.1" 404 181

阿帕奇错误日志:

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

网址的区别是:

发展: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}

~

4

1 回答 1

1

看起来像是区分大小写的问题。Mac OSX(不区分大小写)和 Red Hat(区分大小写)之间的区别。飞行日志控制器和模型不一致:FlightLogs并且Flightlogs都被使用了。

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

...l和L的区别...

于 2013-05-13T21:52:13.320 回答