Laravel没有从URL查询字符串中接收任何$ _GET变量。 $ _GET和Input :: all()都是空的。
示例:
example.app/ex/login.php?country=US
“country = US”从未出现在我的$ _GET变量
中经过大量研究并尝试了许多不同的NGINX配置,我现在只能在使用这个例子时产生结果。
示例:
example.app/index.php/ex/login.php?country=US
$ _GET变量现在显示国家/地区名称值对。
在URL中允许查询字符串的正确配置是什么?
我的“example.app”的当前网站启用配置是......
server {
listen 80;
server_name example.app;
root /home/vagrant/Code/public;
index index.html index.htm index.php;
charset utf-8;
location / {
#try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
access_log off;
error_log /var/log/nginx/registration.app-error.log error;
error_page 404 /index.php;
sendfile off;
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors on;
fastcgi_buffer_size 16k;
fastcgi_buffers 4 16k;
}
location ~ /\.ht {
deny all;
}
}
答案 0 :(得分:5)
除了被注释外,这似乎是正确的。
location / {
#try_files $uri $uri/ /index.php?$query_string;
}
我在测试中使用的裸骨是:
server {
listen 80 default_server;
root /var/www/project/public;
index index.php
server_name localhost;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/php5-fpm.sock;
include fastcgi_params;
}
}
$ query_string和$ args在功能上完全相同: NGINX Docs
答案 1 :(得分:3)
这是支持网站的NGINX服务器配置,最终为我工作......
server {
listen 80;
server_name registration.app;
root /home/vagrant/Code/registration/public;
charset utf-8;
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
access_log off;
error_log /var/log/nginx/registration.app-error.log error;
error_page 404 /index.php;
sendfile off;
# Point index to the Laravel front controller.
index index.php;
location / {
try_files $uri $uri/ index.php?$query_string;
}
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
#deny all;
}
}
答案 2 :(得分:0)
对我来说,它只能通过改变来发挥作用
try_files $uri $uri/ /index.php?$query_string;
来
ubuntu(14.04)nginx
try_files $uri $uri/ /index.php?$args
块内的location /