![我的 nginx 上传入的 $_GET 数组为空](https://linux22.com/image/800424/%E6%88%91%E7%9A%84%20nginx%20%E4%B8%8A%E4%BC%A0%E5%85%A5%E7%9A%84%20%24_GET%20%E6%95%B0%E7%BB%84%E4%B8%BA%E7%A9%BA.png)
我的 nginx 配置如下:
server {
listen 80;
listen [::]:80 default ipv6only=on;
root /www/repos/havi/$subdomain;
index index.php;
server_name domain.com *.domain.com;
set $subdomain "www";
location /
{
try_files $uri $uri/ /index.php;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
}
location ~ /\.ht
{
deny all;
}
if ($host ~* ^([a-z0-9-\.]+)\.domain.com$)
{
set $subdomain $1;
}
}
我不知道为什么如果我尝试通过如下链接设置它,$_GET 数组(php)总是空的:
http://domain.com/action?name=John&age=15
每次都是空数组。在我本地的机器上,本地 Apache 服务器,同样的代码运行正常。
请帮助 ;)
答案1
将用户传递到 index.php 时更改try_files $uri $uri/ /index.php;
为包含 $_GET 参数try_files $uri $uri/ /index.php?$args;