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 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?