uglycode
uglycode

Reputation: 3082

Slim framework + nginx = issues with path

I've tried literally every suggestion on the web and it doesn't seem to work.

I'm using slim framework to create REST services, and I call them in this format:

 http://localhost:8080/myProject/resources/myapp.php/test/

and in myapp.php I have this defined:

$app->get('/test/', ...

when I used xampp this of course worked, but when I migrated to nginx, I get the 404 error.

On the official page they say I should add this to location:

try_files $uri $uri/ /index.php?$args;

I've changed the nginx.conf accordingly:

    location / {
        root   html;
        try_files $uri $uri/ /index.php?$args;
    }

I still get the 'No input file specified.' 404 error.

Any suggestions are greatly appreciated!

Upvotes: 0

Views: 1966

Answers (3)

TDawg
TDawg

Reputation: 883

Kiitos Mika.... that worked perfectly. I had several problems with my routes on production server using nginx. It seemed for me only the subfolders were not working in GET when there were variables, all were getting 404.

Adding the query_string fixed it.

Upvotes: 1

Mika Tuupola
Mika Tuupola

Reputation: 20377

The following in nginx.conf is known to work.

try_files $uri $uri/ /index.php?$query_string;

Upvotes: 0

Im0rtality
Im0rtality

Reputation: 3533

Try this (from URL it appears you are not using index.php, but myapp.php):

try_files $uri $uri/ /myapp.php?$args;

Upvotes: 0

Related Questions