修改$config['uri_protocol']值
改为:
$config['uri_protocol'] = 'PATH_INFO'
2、修改nginx配置文件,在SERVER段中添加如下代码:
location /index.php{
fastcgi_pass unix:/tmp/php-cgi.sock
fastcgi_param SCRIPT_FILENAME /home/wwwroot/index.php
fastcgi_param PATH_INFO $fastcgi_path_info
fastcgi_split_path_info ^(.+\.php)(.*)$
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info
include fcgi.conf
}
如果有多个应用,如:后台应用,可以多加一段以上代码,并修改相应入口文件:
location /admin.php{
fastcgi_pass unix:/tmp/php-cgi.sock
fastcgi_param SCRIPT_FILENAME /home/wwwroot/admin.php
fastcgi_param PATH_INFO $fastcgi_path_info
fastcgi_split_path_info ^(.+\.php)(.*)$
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info
include fcgi.conf
}
首先创建pahtinfo.conf文件touch /usr/local/nginx/conf/pathinfo.conf
然后在这个文件中添加以下内容
vi /usr/local/nginx/conf/pathinfo.conf
set $real_script_name $fastcgi_script_name
if ($fastcgi_script_name ~ "(.+?\.php)(/.*)") {
set $real_script_name $1
set $path_info $2
}
fastcgi_param SCRIPT_FILENAME $document_root$real_script_name
fastcgi_param SCRIPT_NAME $real_script_name
fastcgi_param PATH_INFO $path_info
再将虚拟主机配置文件(/usr/local/nginx/conf/nginx)里的location ~ .*\.(php|php5)?$ 替换为:location ~ .*\.php
再在include fcgi.conf下面添加一行include pathinfo.conf
保存退出;
vi /usr/local/php/etc/php.ini
将cgi.fix_pathinfo=0 修改为cgi.fix_pathinfo=1
[注,上两行不用修改也可以。目前本人不知道是干什么用的。]
保存退出;
重启nginx服务,/etc/init.d/nginx restart
即可支持。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)