我无法在Nginx上的Laravel中检索GET参数

时间:2016-05-24 10:04:16

标签: laravel nginx

我正在使用GET方法,并且URL可以解析参数,如:http://path?param1=123&param2=456。在localhost中,我可以使用Input::all()从表单中获取数据。但在我的服务器上,我使用nginx作为网络服务器,我从Input::all()

得不到任何东西

这是我的.htaccess

Options +FollowSymLinks
RewriteEngine On 

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f    RewriteRule ^ index.php [L]

我很困惑这个错误来自Laravel或我的网络服务器。

这是我的nginx conf

server {
        listen   8080; ## listen for ipv4; this line is default and implied
        #listen   [::]:80 default ipv6only=on; ## listen for ipv6

        root /var/www/path;
        index index.html index.htm index.php;

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

        location /doc/ {
                alias /usr/share/doc/;
                autoindex on;
                allow 127.0.0.1;
                deny all;
        }

        location ~ \.php$ {
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                include fastcgi_params;
        }

}

Apache中一切正常。

1 个答案:

答案 0 :(得分:0)

尝试使用这样的nginx:

server {
    listen   80;

    root /var/www/path;
    index index.php;

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

    location /doc/ {
        alias /usr/share/doc/;
        autoindex on;
        allow 127.0.0.1;
        deny all;
    }

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

之后记得重新启动nginx服务器:sudo service nginx restart