I have an nginx config that looks like this:
location ^~ /movies {
alias /var/dp.cx/movies/current/public;
fastcgi_index index.php;
try_files $uri /movies/index.php;
location ~* \.php {
fastcgi_pass unix:/run/php/php7.1-fpm.sock;
fastcgi_split_path_info ^(.+\.php)(.*)$;
include /etc/nginx/fastcgi_params;
}
}
This is a Laravel application, which works almost completely out of the box. However, there are a couple of small problems that I have with this configuration.
- Hitting
/movies
triggers a 404. Hitting/movies/
works successfully. - Hitting one of the pagination URLs (
/movies/test?page=2
) has no information from the querystring.
I'm not sure where I found this configuration, but it seems to be the closest thing to a "working" configuration I've ever found for nginx + fpm with a subdirectory URL.
To solve it at the server-level... please add the following location block alongside the existing location block for movies...
It is due to
try_files
line that doesn't pass the query string. To pass it, using the followingtry_files
directive would work...Direct quote from http://nginx.org/en/docs/http/ngx_http_core_module.html ...