无法使用Laravel 5.1on远程服务器检索url GET参数

noo*_*ftw 2 php nginx laravel

出于某种原因,我无法使用Illuminate\Http\Request外观从我的控制器中的URL获取任何GET参数.我在多个控制器中测试过,但没有成功.

使用以下代码,访问时远程服务器上不返回任何内容domain.com/admin/dashboard?test=test,但在我的本地计算机上它返回test:

The dashboard function is called by the route /admin/dashboard

/**
 * Dashboard page
 *
 * @return  view
 */
public function dashboard(Request $request)
{
    echo '<pre>';
    var_dump($request->all());
    echo '</pre>';

    // Return here
    return;

    // ...instead of here
    return view('backend::pages.dashboard');
}
Run Code Online (Sandbox Code Playgroud)

我正在使用Nginx和php5-fpm在Ubuntu 14.04 LTS上运行Laravel 5.1.代码在我的本地Homestead实例以及MAMP上运行良好.我检查了我的Nginx配置,一切似乎都很好.我在我的服务器上托管多个站点,我可以在所有其他站点上获取路由参数.

noo*_*ftw 11

如果有人碰到这个问题,问题在于我如何为这个特定的域设置Nginx.

我的/etc/nginx/sites-enabled/default文件中的这个块不适用于查询字符串:

location / {
    try_files       $uri $uri/ /index.php$query_string;
}
Run Code Online (Sandbox Code Playgroud)

将其更改为以下内容后,一切都按原样运行:

location / {
    try_files $uri $uri/ /index.php$is_args$args;
}
Run Code Online (Sandbox Code Playgroud)

希望它可以帮助某人.

  • 5 年过去了,你的帖子仍然有很大帮助 (2认同)