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



我正在使用GET方法,参数可以通过URL解析,如下所示:http://path?param1=123&param2=456。在本地主机中,我可以使用Input::all()从表单中获取数据。但是在我的服务器上,它使用nginx作为网络服务器,我从Input::all()什么也得不到

这是我的.htaccess。

Options +FollowSymLinks
RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f    RewriteRule ^ index.php [L]

我对错误来自Laravel或我的Web服务器感到困惑。

这是我的 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;
        }
}

在阿帕奇中一切正常。

像这样尝试你的nginx conf

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

最新更新