我正在尝试使用 Nginx 运行 PHP 应用程序。重写 URL 可以正常工作,但是查询字符串不会传递给 PHP 文件。我在下面的配置中做错了吗?我将不胜感激任何帮助!
nginx-site.conf:
server {
root /var/www/html;
include /etc/nginx/default.d/.conf;
index index.php index.html index.htm;
client_max_body_size 30m;
server_tokens off;
location / {
index index.html index.htm index.php;
try_files $uri $uri/ @extensionless-php;
}
location ~* .(?:ico|css|js|gif|jpe?g|png|svg|woff)$ {
expires 30d;
add_header Pragma public;
add_header Cache-Control "public";
}
location ~ \.php$ {
fastcgi_param HTTP_PROXY "";
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
}
location @extensionless-php {
if ( -f $document_root$uri.php ) {
rewrite ^ $uri.php last;
}
fastcgi_pass 127.0.0.1:9000;
include fastcgi.conf;
}
location ~* /includes/(.+)\.php$ {
deny all;
}
}