学CI框架,设置了控制器,结果无法按照index.php/class/function 的方式访问,报nginx的错误。
经查是“nginx默认是不支持path_info”。
百度找先人教程最终确认如下:
server
{
listen 80;
server_name localci;
index index.htm index.html index.php;
root F:\localci;#include ci_vhost;
# set expiration of assets to MAX for cachinglocation ~* \.(ico|css|js|gif|jpe?g|png)(\?[0-9]+)?$ {
expires max;
log_not_found off;
}
location / {
# Check if a file exists, or route it to index.php.
try_files $uri $uri/ /index.php;
}
location ~* \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_split_path_info ^(.+\.php)(.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}#ci_vhost end
}
另外注意:CI(CodeIgniter)的config.php 文件,$config['uri_protocol'] = 'AUTO';
还有一个request 正则
if ($request_filename !~* /(admin|static|data|js|css|images|fckeditor|userfiles|crontab|robots\.txt|index\.php)) {
rewrite ^/(.*)$ /index.php?$1 last;
}
原文地址 http://www.kukaka.org/home/content/611