Laravel 4.2无法访问查询参数

时间:2014-11-19 08:48:01

标签: php laravel nginx get

我正在使用 laravel 4.2 nginx ,使用简单的Get路线,我无法使用'输入:: get(&)访问查询参数#39; id')' 。如果我尝试 Request :: fullUrl(),即使我提供了,也没有看到任何查询参数。

我的路线是:

Route::get('user' , 'UserController@show');

在控制器中我只是使用,

Input::get('name');

并访问路线,如:

localhost/user?name=foo

Nginx配置是:

server {
        listen 80;
       root /home/ubuntu/project/public;
       index index.html index.php;
       server_name  localhost;



       # set expiration of assets to MAX for caching
        location ~* \.(html|ico|css|js|gif|jpe?g|png)(\?[0-9]+)?$ {
                expires max;
                log_not_found off;
        }

       location / {
                # First attempt to server request as file, then
                # as directory, then fall back to displaying a 404
        try_files $uri $uri/ /index.php;
       }

       location /doc/ {
                alias /usr/share/doc/;
                autoindex on;
                allow 127.0.0.1;
                allow ::1;
                deny all;
       }
       error_page 404 /404.html;

       location ~ \.php$ {
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                fastcgi_param PATH_INFO $fastcgi_script_name;
                fastcgi_param QUERY_STRING $query_string;
                fastcgi_read_timeout 36000;
                include fastcgi_params;
       }

       location /server-status {
              stub_status on;
              access_log off;
              allow all;
       }

}

1 个答案:

答案 0 :(得分:1)

在你的nginx网站配置中,你应该像这样添加$query_string

location / {
    try_files $uri $uri/ /index.php?$query_string;
}