您的位置:首页 > 运维架构 > Nginx

Nginx/PHP/path_info问题,去掉index.php

2010-04-22 22:33 543 查看
作用是把形如:www.abc.com/index.php/blog/show 的地址美化成 www.abc.com/blog/show ,使用$_SERVER['PATH_INFO']接收变量。

server
{
listen       80;
server_name  myweb;
index index.html index.htm index.php;
root  /home/zhaowei/code;
if (!-f $request_filename) {
rewrite ^/m-php-framework/(.*)$ /m-php-framework/index.php/$1 last;
}
location ~ .*/.(php|php5)
{
#fastcgi_pass  unix:/tmp/php-cgi.sock;
fastcgi_pass  127.0.0.1:9000;
fastcgi_index index.php;
include fcgi.conf;
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 /home/zhaowei/code$real_script_name;
fastcgi_param SCRIPT_NAME $real_script_name;
fastcgi_param PATH_INFO $path_info;
}
log_format  wwwlogs  '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" $http_x_forwarded_for';
access_log  /data1/logs/wwwlogs.log  wwwlogs;
}


#nginx -s reload 重启NGINX
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: