Noob, 404 ERROR when not including index.php


#1

I am just getting started and have run into a issue. I followed the tutorial located at https://www.slimframework.com/docs/tutorial/first-app.html . I fire up the php dev server like this:

php -S 172.16.27.190:5500

I go to this URL: http://172.16.27.190:5500/hello/bob and the web page shows Hello, bob … so far so good. Now I move the same index.php file to ~/src/public/app/api/v1/

now I go to http://172.16.27.190:5500/app/api/v1/hello/bob and I get 404: File not found.

So I made a info.php file with <?php phpinfo(); ?> in it and go to http://172.16.27.190:5500/app/api/v1/info.php … it WORKS !

At this point I try to go to http://172.16.27.190:5500/app/api/v1/index.php/hello/bob and it WORKS ! Keep in mind I am running the php dev server so an .htaccess file won’t help. Why does the rewrite work with / but not /app/api/v1/ ? and how can I fix it ?


#2

You may want to read http://php.net/manual/en/features.commandline.webserver.php

Specifically, php -S will only look for a default index.php in the directory where it was started unless you use the -t option in which case it will look in that directory for a default index.php.

Slim is intended to be used in such a way that index.php is in public and you create a new route for /app/api/v1/.