I'm using Laravel, but I assume it could be any PHP framework (e.g. Symfony).
I have the following Nginx config:
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location = /index.php {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}
I'm making this request and everything works fine:
GET /v3/action/1332899709/some-endpoint?page=1
As far as I understand, nginx transforms this request to just /index.php?page=1
. So, why does this work? How does Laravel know what uri have I requested? Does nginx pass some request data "under the hood", while checking endpoints in try_files
?
The routing is done with the help of fastcgi_params
, such as SCRIPT_FILENAME
, REQUEST_URI
etc.