I THINK I made some progress today. I forked the buildpack and added
LogLevel alert rewrite:trace6
to defaults/config/httpd/2.4.x/extra/httpd-logging.conf to get some
logging about the routing was being done. After being able to see
what the URLs ended up looking like I changed my http-php.conf to
RewriteCond $1 ^/?(api.*)$
RewriteRule ^/?(.*)$ index.php/$1 [QSA,L]
After doing this I can see my URLs look like they are being rewritten
correctly. My static resources (HTML, CSS, JS) can be rendered and my
REST API is being redirected to my php file.
From the logs...
20:13:00 httpd | [Tue Mar 25 20:13:00.660862 2014]
[rewrite:trace2] [pid 55:tid 139666132276992] mod_rewrite.c(475):
[client
75.126.23.243:40712] 75.126.23.243 - -
[
myapp.cf.com/sid#23df320][rid#24701f0/initial] init rewrite engine
with requested uri /api/todos
20:13:00 httpd | [Tue Mar 25 20:13:00.660911 2014]
[rewrite:trace3] [pid 55:tid 139666132276992] mod_rewrite.c(475):
[client
75.126.23.243:40712] 75.126.23.243 - -
[
myapp.cf.com/sid#23df320][rid#24701f0/initial] applying pattern
'^/?(.*)$' to uri '/api/todos'
20:13:00 httpd | [Tue Mar 25 20:13:00.660957 2014]
[rewrite:trace4] [pid 55:tid 139666132276992] mod_rewrite.c(475):
[client
75.126.23.243:40712] 75.126.23.243 - -
[
myapp.cf.com/sid#23df320][rid#24701f0/initial] RewriteCond:
input='api/todos' pattern='^/?(api.*)$' => matched
20:13:00 httpd | [Tue Mar 25 20:13:00.660971 2014]
[rewrite:trace2] [pid 55:tid 139666132276992] mod_rewrite.c(475):
[client
75.126.23.243:40712] 75.126.23.243 - -
[
myapp.cf.com/sid#23df320][rid#24701f0/initial] rewrite '/api/todos'
-> 'index.php/api/todos'
20:13:00 httpd | [Tue Mar 25 20:13:00.660991 2014]
[rewrite:trace2] [pid 55:tid 139666132276992] mod_rewrite.c(475):
[client
75.126.23.243:40712] 75.126.23.243 - -
[
myapp.cf.com/sid#23df320][rid#24701f0/initial] local path result:
index.php/api/todos
20:13:00 httpd | 75.126.23.243 - - [25/Mar/2014:20:13:00 +0000]
"GET /api/todos HTTP/1.1" 400 226
So what is happening is my client side code is making a request to
/api/todos which is being rewritten as index.php/api/todos. index.php
contains my Slim app code and index.php/apis/todos is a valid URL to
access the REST APIs [1]. Yet as you can see the server is returning
a 400. I cannot figure out why I am getting a 400 back. One odd
thing I noticed is if I go to index.php directly I see the PHP source
code while I would expect it to be evaluating the PHP code. How can I
figure out where the 400 is coming from?
[1]
http://docs.slimframework.com/#Route-URL-Rewriting