dongnan1989 2015-08-22 08:55
浏览 60
已采纳

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

For some reason I can't get any GET parameters from a url in my controllers using the Illuminate\Http\Request facade. I tested in multiple controllers, but no success.

Using the following code, nothing is returned on the remote server when accessing domain.com/admin/dashboard?test=test, but on my local machine it returns 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');
}

I'm running Laravel 5.1 on Ubuntu 14.04 LTS using Nginx and php5-fpm. The code works fine on my local Homestead instance as well as on MAMP. I checked my Nginx configuration and everything seems fine. I'm hosting multiple sites on my server and I can get route parameters on all other sites.

  • 写回答

2条回答 默认 最新

  • dptpn06684 2015-08-24 12:23
    关注

    If anyone runs into this, the problem was with how I set up Nginx for this particular domain.

    This block in my /etc/nginx/sites-enabled/default file didn't work with query strings:

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

    After changing it to the following, everything worked as it supposed to be:

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

    Hope it helps someone.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作