以前都是用Apache的re-write来使用yii,没有出现过问题,现在换到nginx后,发现隐藏index.php是个很大的问题。
cookbook里有一个讲解如何隐藏index.php帖子,我照着试了却出错,请大家指点我。
贴出我的nginx配置:
server {
listen 91;
server_name localhost;
access_log /var/log/nginx/localhost.access_log main;
error_log /var/log/nginx/localhost.error_log info;
location / {
if (!-e $request_filename) {
rewrite (.*) /index.php/$1 break;
}
root /home/icefox/shiehnews-yii/shiehnews;
index index.php index.html;
}
location ~ .php$ {
root /home/icefox/shiehnews-yii/shiehnews;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_param PATH_INFO $fastcgi_script_name;
}
}
myuid
(Hilcs)
3
这是我现在用的,你看看行不
location / {
root html;
index index.php index.html index.htm;
if (!-e $request_filename) {
rewrite (.*) /index.php;
}
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ .php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ .php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_script_name;
access_log off;
}
gdtv
(Gdtv)
5
我的是
location / {
if (!-e $request_filename){
rewrite (.*) /index.php last;
}
}
注意加了个 "last"
谢谢两位~成了!
哈哈~开始在nginx下跑Yii了~现在的开发完全在Gentoo下了,嘿嘿.