Pergunta

I am working on a simple REST API, it is working on my development system (Mac OSX, Zend Studio, Zend Server CE - http://localhost:10088/apitest/) with RewriteBase in the .htaccess files (see below). I modified the .htaccess files to use the Apache 2.2 virtual host I created (https://api.domain.com/) and I am receiving 404 errors. The only changes are the (1) RewriteBase lines in .htaccess, https: access in the url.

Error response:

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

** The commented RewriteBase lines below are working in development. **

/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 rewrite log:

[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

I can stat the final path: /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 Virtual Host:

<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 access log:

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

Apache error log:

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

The url difference are:

Development: http://localhost:10088/apitest/v1/flightlogs/9230.xml

Production: https://api.domain.com/v1/flightlogs/9230.xml

Something should be hitting me in the face, I can can not see it. Any ideas?

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

~

Foi útil?

Solução

Looks like a case sensitivity issue. Difference between Mac OSX (not case sensitive) and Red Hat (case sensitive). The Flight logs controller and model were inconsistent: FlightLogs and Flightlogs were both used.

I located all instances of Flightlogs and changed them to FlightLogs and the error seems to have gone away.

...The difference between l and L...

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top