2011-09-08 39 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