Laravel 5 - URL 查询字符串的 NGINX 服务器配置问题

Laravel 5 - NGINX Server Config Issue with URL Query Strings

Laravel 没有从 URL 查询字符串中接收到任何 $_GET 变量。 $_GET 和 Input::all() 是空的。

示例:

例子.app/ex/login.php?country=US

"country=US" 从未出现在我的 $_GET 变量中

经过大量研究并尝试了许多不同的 NGINX 配置,我现在只能在使用此示例时产生结果。

示例:

示例。app/index.php/ex/login.php?国家=美国

$_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;
}

}

除了被注释掉之外,这似乎是正确的。

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

这是支持站点的 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;
    }
}

对我来说,它只通过改变 try_files $uri $uri/ /index.php?$query_string;try_files $uri $uri/ /index.php?$argslocation / 块内 ubuntu (14.04) nginx