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 PADS Logic 原理图
  • ¥15 PADS Logic 图标
  • ¥15 电脑和power bi环境都是英文如何将日期层次结构转换成英文
  • ¥20 气象站点数据求取中~
  • ¥15 如何获取APP内弹出的网址链接
  • ¥15 wifi 图标不见了 不知道怎么办 上不了网 变成小地球了
  • ¥50 STM32单片机传感器读取错误
  • ¥15 (关键词-阻抗匹配,HFSS,RFID标签天线)
  • ¥15 机器人轨迹规划相关问题
  • ¥15 word样式右侧翻页键消失