在 Nginx 低版本中,是不支持 PATHINFO 的,但是可以通过在 Nginx.conf 中配置转发规则实现(domain.com/index.php?s=path_info)
>cd /usr/local/nginx/conf/
>vi nginx.conf
>lnmp restart
[i] //插入内容
code[nginx.conf] {
server {
listen 80;
server_name localhost;
index index.html index.htm index.php;
root /home/wwwroot/default;

location / {
if (!-e $request_filename){
rewrite ^/member/(.*)$ /member/index.php?sss=/$1 last;

rewrite ^/(.*)$ /index.php?sss=/$1 last;
}
}

location ~ .*\.(php|php5)?$
{
#fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;

# 以下是为了让Nginx支持PATH_INFO
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;

fastcgi_connect_timeout 120;
fastcgi_send_timeout 120;
fastcgi_read_timeout 120;
fastcgi_buffers 8 128K;
fastcgi_buffer_size 128K;
}

location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}

location ~ .*\.(js|css)?$
{
expires 1h;
}

#伪静态规则
access_log /alidata/log/nginx/access/default.log;
}
}
[Esc] //退出插入
[:wq] //保存并退出
>service nginx restart

作者 admin

百度广告效果展示