Slim 3 without URL rewriting

I’m using Monkey HTTP server which unfortunately does not implement url rewriting.
Tried following steps here: http://docs.slimframework.com/routing/rewrite/.
Though root ‘/’ route works, all other routes don’t.

'http://127.0.0.1:2001/index.php => works!
'http://127.0.0.1:2001/index.php/hello => goes to root route
'http://127.0.0.1:2001/index.php/testroute/1=> goes to root route

By the way, also tested the same app with lighttpd server (which implements url rewrite), and everything works as expected.

Slim uses $_SERVER['SCRIPT_NAME'] and $_SERVER['REQUEST_URI'] to determine the route.
Maybe Monkey HTTP server does not set those properly?

Can you post the contents of the $_SERVER variable?

Accessed: http://127.0.0.1:2001/public/index.php/hello

Contents of $_SERVER variable:
Array (
[USER] => nobody
[HOME] => /dev/null
[FCGI_ROLE] => RESPONDER
[GATEWAY_INTERFACE] => CGI/1.1
[REDIRECT_STATUS] => 200
[SERVER_SOFTWARE] => Monkey/1.6.9
[SERVER_PROTOCOL] => HTTP/1.1
[SERVER_NAME] => 127.0.0.1
[DOCUMENT_ROOT] => /usr/monkey/var/www/testsite
[SERVER_ADDR] => 192.168.254.34
[SERVER_PORT] => 2001
[REMOTE_ADDR] => 192.168.254.124
[REMOTE_PORT] => 33516
[SCRIPT_FILENAME] => /usr/monkey/var/www/testsite/public/index.php
[SCRIPT_NAME] => /public/index.php/hello
[REQUEST_METHOD] => GET
[REQUEST_URI] => /public/index.php/hello
[HTTP_HOST] => 192.168.254.34
[HTTP_CONNECTION] => keep-alive
[HTTP_ACCEPT] => text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,/;q=0.8
[HTTP_UPGRADE_INSECURE_REQUESTS] => 1
[HTTP_USER_AGENT] => Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36
[HTTP_ACCEPT_ENCODING] => gzip, deflate, sdch
[HTTP_ACCEPT_LANGUAGE] => en-US,en;q=0.8
[ORIG_SCRIPT_FILENAME] => /usr/monkey/var/www/testsite/public/index.php/hello
[PATH_TRANSLATED] => /usr/monkey/var/www/testsite
[PHP_SELF] => /public/index.php/hello
[REQUEST_TIME_FLOAT] => 1466651738.7757
[REQUEST_TIME] => 1466651738
[argv] => Array ( )
[argc] => 0
)

Appreciate the help! Thanks :slight_smile:

If I check my Apache environment I see this:

// mine
[REQUEST_URI] => /info.php/blah
[SCRIPT_NAME] => /info.php

// yours
[REQUEST_URI] => /public/index.php/hello
[SCRIPT_NAME] => /public/index.php/hello 

Slim removed the SCRIPT_NAME from the REQUEST_URI and uses blah as the route.
In your case if you remove SCRIPT_NAME from the REQUEST_URI nothing it left!

I guess that’s what goes wrong.

I have no idea if this is a bug in your http server or not.

Nice observation, thanks!

Also noticed that there’s no entry for [PATH_INFO], any idea if this is used by Slim?
Anyway, I’ll try asking this from the Monkey forums too.

I don’t think PATH_INFO is used.

Checkout this method to see what is used: