I have a Javascript app that uses Slim (slimframework.com) as the API endpoint.
I have used this for quite a while on my previous computer (win 8), but moved it and now its running on OSX (Apache 2.4.9 php 5.5).
Strange thing is that after this migration, whatever GET routes i try, they all route to / (the default route). when i try to get the path of the request (as you can see in the '/' route) it shows the correct request.
I picked it all apart and set up the most minimal layout. Same results.
php:
require 'Slim/Slim.php';
\Slim\Slim::registerAutoloader();
$app = new \Slim\Slim();
$app->get('/hello/:name', function ($name) {
echo "Hello, $name";
});
$app->get('/', function () use ($app) {
echo "root" . $app->request()->getPath();
});
$app->run();
Calling /hello/world should return the string "Hello, world". But instead it returns "root /hello/world/" note the trailing slash.. This goes for any other route as well (ie /hello/world/and/other/planets/as/well returns "root/hello/world/and/other/planets/as/well/").
I am wondering wether this has something to do with my virtualhost config (but i have many apps that use url rewriting, and that seems to work)
httpd-vhost.conf
<VirtualHost *:80>
ServerName stage_api.loc
ServerAlias stage_api.loc
DocumentRoot "[the correct dir]"
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) /index.php [L,QSA]
<Directory "[the correct dir]">
Options Indexes FollowSymlinks MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Strange thing is that if i omit FollowSymLinks from the vhost config, the whole thing fails.
Something I'm missing here? Any help appreciated.
B
UPDATE: Fearing to be seen as slightly OCD... but I added print_r($_SERVER); to index.php, and all seems correct
Array
(
[SCRIPT_URL] => /hello/world
[SCRIPT_URI] => http://stage_api.loc/hello/world
[HTTP_HOST] => stage_api.loc
[HTTP_CONNECTION] => keep-alive
[HTTP_CACHE_CONTROL] => no-cache
[HTTP_USER_AGENT] => Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.99 Safari/537.36
[HTTP_ACCEPT] => */*
[HTTP_ACCEPT_ENCODING] => gzip, deflate, sdch
[HTTP_ACCEPT_LANGUAGE] => en,en-US;q=0.8,nb;q=0.6
[PATH] => [removed by user]
[SERVER_SIGNATURE] =>
[SERVER_SOFTWARE] => Apache/2.4.9 (Unix) OpenSSL/0.9.8za PHP/5.5.14
[SERVER_NAME] => stage_api.loc
[SERVER_ADDR] => 127.0.0.1
[SERVER_PORT] => 80
[REMOTE_ADDR] => 127.0.0.1
[DOCUMENT_ROOT] => [removed by user]
[REQUEST_SCHEME] => http
[CONTEXT_PREFIX] =>
[CONTEXT_DOCUMENT_ROOT] => [removed by user]
[SERVER_ADMIN] => you@example.com
[SCRIPT_FILENAME] => [removed by user]/index.php
[REMOTE_PORT] => [removed by user]
[GATEWAY_INTERFACE] => CGI/1.1
[SERVER_PROTOCOL] => HTTP/1.1
[REQUEST_METHOD] => GET
[QUERY_STRING] =>
[REQUEST_URI] => /hello/world
[SCRIPT_NAME] => /hello/world
[PHP_SELF] => /hello/world
[REQUEST_TIME_FLOAT] => 1421675412.017
[REQUEST_TIME] => 1421675412
[argv] => Array
(
)
[argc] => 0
)