You are viewing revision #1 of this wiki article.
This version may not be up to date with the latest version.
You may want to view the differences to the latest version.
nginx+fastcgi+php方式下隐藏index.php需要注意几个问题
一个是配置PATH_INFO,不然无法使用yii urlManager的path格式 记得加上"fastcgi_param PATH_INFO $fastcgi_script_name; "这行
location ~ \.php {
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;
}
还有一个是rewrite规则
location /yiiGuestbook {
if (!-e $request_filename){
rewrite (.*) /yiiGuestbook/index.php/$1;
}
}
Apache hiding index.php请看:(http://www.yiiframework.com/doc/guide/topics.url)
Problems in root directory solved.
So I originally had issues with multipaged listviews. I was running scripts from root directory things weren't getting parsed correctly. You might want to add this to the wiki entry.
My nginx (v. 0.8.5) rule is:
location / {
try_files $uri $uri/ /index.php;
}
Before having
location / {
try_files $uri $uri/ /index.php?r=$request_uri;
}
Was causing problems.
Hope this helps someone!
try_files
When using try_files with index.php?r=$request_uri; I had an endless 302 loop (using nginx 1.0.5). using try_files with just index.php as suggested by SniperZero fixed the problem.
Another try_files option
In some cases try_files last uri should be changed to:
try_files $uri $uri/ /yiiGuestbook/index.php$request_uri;
I think(in my case) this depends on if you are splitting path_info, i.e using fastcgi_split_path_info.
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.