Welcome! Log In Create A New Profile

Advanced

try_files not working as expected

Posted by Psyered 
try_files not working as expected
May 25, 2015 12:14PM
Hi,

location /some/location/ {
try_files $uri /api.php?r=$request_uri;
}

Is working perfectly. It does process domain.com/some/location/ as domain.com/api.php?r=/some/location/ (.php files processed in other location).

But

location /some/location/ {
try_files $uri /api.php?r=$request_uri =404;
}

Is always returning 404 error code.
Why this happening? What I am doing wrong?
Re: try_files not working as expected
May 25, 2015 01:03PM
Something similar http://stackoverflow.com/questions/18117625/how-to-configure-nginx-to-try-files-first-if-not-exists-follow-the-request-uri

---
nginx for Windows http://nginx-win.ecsds.eu/
Re: try_files not working as expected
May 30, 2015 04:29AM
Not so similar. We want to perform kind of rewrite with try_files.
If user hit "/some/location/, try_files should search for /api.php?r="/some/location" (api.php file exists)
I think the problem is at "?r=". But why it works perfect without "=404" at the end?
Re: try_files not working as expected
May 30, 2015 05:37AM
Because the last tryfiles value is taken into consideration, which seems to always be true. Without it the api is always true.

---
nginx for Windows http://nginx-win.ecsds.eu/
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 182
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready