为什么nginx $request_uri 只包含一个参数?

Why nginx $request_uri contains only one parameter?

我的 nginx 配置:

server {
    listen 80;
    server_name test.app;
    location / {
      echo $request_uri;
    }
}

然后我通过 curl 执行 GET 请求,我只能看到第一个参数。所有其他人都丢失了:

# curl http://test.app?p1=v1&p2=v2
> /?p1=v1

据我所知,$request_uri 应该包含所有 GET 参数。为什么他们迷路了?

Nginx 是通过 apt-get 安装的。

如果您在命令行上执行 curl,则必须转义 & 否则您将执行 curl http://test.app?p1=v1 并将其发送到后台。

curl http://test.app?p1=v1\&p2=v2 应该可以解决问题。