Zend框架额外的获取参数与NGINX [英] Zend Framework additional Get params with NGINX
问题描述
我以下面的方式为PHP配置了我的NGINX(PHP 5.3和fpm):
server {
root / home / page / public /;
index index.php index.html index.htm;
server_name localhost;
位置/ {
try_files $ uri $ uri / /index.php;
}
位置〜\.php $ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $ document_root $ fastcgi_script_name;
包含fastcgi_params;
}
位置〜/\.ht {
拒绝所有;
$ / code $ / pre
现在我想要处理额外的获取参数:< a href =http://web.site/index?par=1 =nofollow> http://web.site/index?par=1
使用我的本地开发系统(Apache),它可以正常工作,但不在NGINX下,它不会提供获取参数。
Anny suggestions?
编辑:
现在我使用以下配置,似乎可行,但我不满意,因为每个人建议尽可能使用try_files。
location / {
if(!-e $ request_filename){
rewrite /(.*)$ /index.php?q=$1 last;
休息;
$ div $解析方案
Nginx文档( http://wiki.nginx.org/HttpCoreModule#try_files ):
如果您需要保存args,您必须明确地这样做:
位置/ {
try_files $ uri $ uri / /index.php?args;
}
I configured my NGINX for Zend in the following way (PHP 5.3 with fpm):
server {
root /home/page/public/;
index index.php index.html index.htm;
server_name localhost;
location / {
try_files $uri $uri/ /index.php;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}
Now i want to process additional get params like: http://web.site/index?par=1
WIth my local dev system (Apache) it works fine but not under NGINX which did'T deliver the get params.
Anny suggestions?
Edit:
Now i use the following config which seems to work but i'm not happy with it since everybody suggests "use try_files whenever possible".
location / {
if (!-e $request_filename) {
rewrite /(.*)$ /index.php?q=$1 last;
break;
}
}
From Nginx docs ( http://wiki.nginx.org/HttpCoreModule#try_files):
If you need args preserved, you must do so explicitly:
location / {
try_files $uri $uri/ /index.php?$args;
}
这篇关于Zend框架额外的获取参数与NGINX的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!