简体   繁体   English

Laravel 5.1 GET URL参数密钥不正确传递给控制器

[英]Laravel 5.1 GET url parameter key not correct passing to controller

I have a problem with getting GET params from URL. 我从URL获取GET参数有问题。

If I have eg 如果我有例如

http://domain.tld/route?page=2

And than in controller I dd data from GET with 比起在控制器中,我从GET获取dd数据

dd(Input::all());

Laravel return is Laravel返回是

array:1 [▼
  "//route?page" => "2"
]

But should be 但是应该

array:1 [▼
  "page" => "2"
]

The problem exists on Laravel 5.1 on 5.0 there is all ok. 在5.0上的Laravel 5.1上存在问题,一切正常。

Route code is 路线代码为

Route::get('/klub', ['as' => 'teamInfo', 'uses' => 'Game\Team\TeamController@index']);

Contoller code is 控制器代码为

final public function index(Request $request)
    {
        $userTeam = UserCache::get('team');
        if ($userTeam->id > 0)
            return view('game.team.info')->with(['userTeam' => $userTeam]);
        else {
            //this is executing in my case
            $proposals = Teams::proposals()->paginate(1);
            return view('game.team.empty', ['teamLimits' => conf('team.php'), 'userTeam' => $userTeam, 'proposals' => $proposals]);
        }
    }

var_dump($_SERVER['QUERY_STRING']);
string(13) "//klub?page=2"

var_dump($_SERVER['REQUEST_URI']);
string(12) "/klub?page=2" 

Something is corrupted in whatever server you're using (NGINX or Apache?). 您正在使用的任何服务器(NGINX或Apache?)中都有某些损坏。 The server variables are passed through to PHP from the server engine and PHP can only parse what it's given. 服务器变量从服务器引擎传递到PHP,PHP只能解析给定的变量。

You may have a bad URL rewrite in your .htaccess if you're using Apache or NGINX may be forwarding the value incorrectly. 如果您使用的是Apache,则您的.htaccess URL重写可能不正确,否则NGINX可能会错误地转发该值。 The QUERY_STRING should be page=2 . QUERY_STRING应该是page=2

@dboskovic the problem was with nginx configuration, wrong variable passed to cgi, I now fix it and all works great. @dboskovic问题出在nginx配置上,错误的变量传递给了cgi,我现在将其修复,并且一切正常。

Thanks so much for help and 非常感谢您的帮助和

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM