2011-09-08 66 views
0

我配置我NGINX为Zend公司以下列方式(PHP 5.3 FPM):Zend框架额外获取PARAMS与NGINX

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; 
} 
} 

现在我要处理其他get PARAMS,如:http://web.site/index?par=1

与我的本地开发系统(Apache)工作正常,但不在NGINX下,它没有提供获取参数。

Anny的建议?

编辑:

现在我用下面的配置,这似乎工作,但我不喜欢它,因为每个人都建议“使用try_files尽可能”。

location/{ 
    if (!-e $request_filename) { 
     rewrite /(.*)$ /index.php?q=$1 last; 
     break; 
    } 
} 
+0

如何其实你是否试图得到它? – zerkms

+0

用print_r($ _GET)测试它,但后来用$ values = $ this-> getRequest() - > getQuery(); – Johni

+0

问题不是脚本问题是认为脚本文件名是index.php没有参数,所以php不能填充$ _GET数组等。 – Johni

回答

-1

我为此使用了一个rewrite module;尝试更换您location /块以下几点:

location/{ 
    index index.php index.html index.htm; 
} 

if (!-e $request_filename) { 
    rewrite ^.*$ /index.php last; 
} 
+0

是的,这个作品我已经尝试过了,并且即将编辑我的问题,但大家都说“尽可能使用try_files”,所以我仍然对它的解决方案感兴趣。 – Johni