Chinaunix首页 | 论坛 | 博客
  • 博客访问: 45268
  • 博文数量: 6
  • 博客积分: 1647
  • 博客等级: 上尉
  • 技术积分: 75
  • 用 户 组: 普通用户
  • 注册时间: 2010-05-21 15:08
文章分类
文章存档

2012年(2)

2011年(2)

2010年(2)

分类: LINUX

2012-05-16 13:44:45

很多PHP框架默认使用PHP的PATH_INFO 来进行URL重写,当用Nginx作为http服务器的时候,就出现问题了,无法进行重写,导致访问404,当我们想要使用PHP框架的PATH_INFO重写时,就要为Nginx定义PATH_INFO这个变量。 

               location ~ .*\.(php|php5)?$ {
                #fastcgi_pass  127.0.0.1:9000;
                fastcgi_pass  unix:/tmp/php-cgi.socket;
                fastcgi_index index.php;
                set $path_info "";
                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;
                include fastcgi.conf;
                }

注意去掉(php|php5)?$  后面的$
阅读(1610) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~