Path issue (404) on some routes using PHP builtin webserver

Hello,

My Slim is working well in my development env (a virtual host in my apache config).
But trying to run it using the PHP webserver gives strange results on some pages :confused: I’ll try to explain what happens.

I run php -S localhost:8888 from my public directory, that contains the index.php main file.

I’ve a page that should display a map, and have to load CSS, JS and images.
I’ve a route for the page itself, and another one to load resources, since they’re out of the public directory.
The URL http://localhost:8888/plugins/maps/carte show the page, but resource calls, like http://localhost:8888/plugins/plugin-maps/res/images/maps.png don’t work.

I have a 404 error on this last call; that come directly from the webserver and not from Slim.
But if I change the URL to http://localhost:8888/index.php/plugins/plugin-maps/res/images/maps.png (note the add of /index.php); I can get the image!

Well, that could be logic; but I do not understand why some routes works well without index.php and others don’t… Could someone explain what I’m missing?

For reference, the resource route is defined here:

Thanks!

I have a similar situation but I’m getting the 404 error only for one of my 8 routes. It is a POST and it works perfectly in my localhost apache server but it won’t on my hosting account. I’m using Slim v2 though. Here’s a link to my post in case you want to check it out.

Hey there,

So, this is a PHP embed webserver issue: there is a simple automatic rewrite that is active; which explains why in the page URL I do not have the index.php. But if there is any dot in the URL; the rewrite will not work…

So, every URL like /path/to/image.png or /path/to/lib-1.2.3/myfile will not work!

This looks similar to a question in an earlier thread:

http://discourse.slimframework.com/t/routing-with-floats-in-the-url/1195

You can provide a router script when starting the PHP built-in web server to make sure index.php is called.

Hello,

Yes, I know this is possible; we’ve used that on another project to make automated testing to work.

I’ve tried with current issue… But this did not solved the initial problem, I kept lost with the automatic redirection stuff anyways :slight_smile: