【问题标题】:Nginx Laravel GET request doesn't send arrayNginx Laravel GET 请求不发送数组
【发布时间】:2020-01-23 17:20:20
【问题描述】:

我将 Laravel 与 NGINX 一起使用,但由于某种原因我无法接收 GET 请求。它们与 Apache (XAMPP) 完美配合。

这是我要传递的参数的 URL:

/table-search-client?model=Client&column=name&search=UAB

在此示例的控制器中,我使用 dd() 仅显示传入的数组。这就是我使用 Apache 得到的(正确):

array:3 [
  "model" => "Client"
  "column" => "name"
  "search" => "UAB"
]

这是我使用 Nginx 得到的(不正确):

array:1 [
  "query_string" => null
]

Post 方法效果很好,但我想使用 Laravel 的分页,据我了解,这需要 GET 方法。

我认为这是某种配置问题,但我不知道在 Nginx 配置文件中编辑什么以及在哪里编辑。

有什么建议吗?

【问题讨论】:

    标签: laravel apache nginx get


    【解决方案1】:

    所以我设法在位于 etc/nginx/sites-available/default 的 NGINX 配置文件中找到了问题。

    我之前的配置是这样的:

    location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ /index.php?query_string;
        }
    

    由于某些原因,在安装 Nginx 时,$ 符号被遗漏了。所以我只需要在query_string之前添加它,重启Nginx,一切就开始工作了。所以最终的配置看起来像这样:

    location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ /index.php?$query_string;
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-09-04
      • 1970-01-01
      • 2018-04-23
      • 2023-03-18
      • 1970-01-01
      • 2016-04-18
      • 1970-01-01
      相关资源
      最近更新 更多