Joh*_*hni 0 php zend-framework get nginx
我按照以下方式配置我的NGINX for Zend(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;
}
}
Run Code Online (Sandbox Code Playgroud)
现在我想处理额外的get params,例如:http://web.site/index?par = 1
与我的本地开发系统(Apache)一样,它可以正常工作但不在NGINX下,它没有提供获取参数.
安妮的建议?
编辑:
现在我使用以下配置似乎有效,但我对它不满意,因为每个人都建议"尽可能使用try_files".
location / {
if (!-e $request_filename) {
rewrite /(.*)$ /index.php?q=$1 last;
break;
}
}
Run Code Online (Sandbox Code Playgroud)
来自Nginx docs(http://wiki.nginx.org/HttpCoreModule#try_files):
如果您需要保留args,则必须明确地执行此操作:
location / {
try_files $uri $uri/ /index.php?$args;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1350 次 |
| 最近记录: |