I'm having a problem getting nginx configuration to work. Seems like everything works fine but my php script does not receive GET parameters. The most relevant link I get on my issue is this one nginx + php-fpm - where are my $_GET params? But my config is slightly different and simply adding $query_string to the last try_files directive just doesn't work.
Here's my config:
server {
server_name api.example.com;
root /home/example/api/web;
location /v2 {
alias /home/example/api/v2/web;
try_files $uri /v2/index.php;
location ~* \.(js|css|less|png|jpg|jpeg|gif|ico|woff|ttf|svg|tpl)$ {
expires 24h;
access_log off;
}
location /v2/index.php {
fastcgi_index index.php;
fastcgi_pass php56;
fastcgi_split_path_info ^/v2/(.+\.php)(.*)$;
fastcgi_param SCRIPT_FILENAME /home/example/api/v2/web/$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_NAME /v2/index.php;
}
}
}
Then using this config, /v2
URL does not see GET, while /v2/index.php
does. If I change try_files line to try_files $uri /v2/index.php$query_string;
, /v2
URL just gives me 404.
Okay, one good guy helped me with that. Here's the working config: