Laravel with Nginx parameters are empty
It is best to avoid unneccessary rewrites in your nginx configuration (See Nginx Pitfalls), one in particular is the one responsible for passing the request to the Laravel front controller:
All you need for Laravel is:
location / { index index.php index.html index.htm; try_files $uri $uri/ index.php?$query_string;}
First that tries to access a file directly, then a directory, and if neither exists it passes the request to index.php. $query_string
is important to pass along as that will contain the $_GET
data that otherwise gets lost.
And here is my own FastCGI configuration piece:
location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name; include fastcgi_params;}
As for unexpected input, it could be the way your current rewrite works, but to say for sure, what are you outputting?
This works for me:
location / { index index.php; try_files $uri $uri/ /index.php?q=$uri&$args;}location ~ \.php$ { include fastcgi_params; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;}
From your config:
rewrite ^/(.*)$ /index.php?/$1 last;
here you have a redirect to /index.php?/$1
(e.g. /index.php?/some/path
).
fastcgi_split_path_info ^(.+\.php)(/.+)$;
and here you spilt path by ^(.+\.php)(/.+)$
regex (e.g. /index.php/some/path
).
Have you noticed the difference?