Nginx 开启 path_info功能

server {
        listen       80;
        server_name  localhost;
        
        #charset koi8-r;

        #access_log  logs/host.access.log  main;
        root   "E:/phpStudy/WWW";
        
        location / {
            index  index.html index.htm index.php l.php;
            autoindex  off;
            #如果请求既不是一个文件,也不是一个目录,则执行一下重写规则
            if (!-e $request_filename)
            {
              #地址作为将参数rewrite到index.php上。
              rewrite ^/(.*)$ /index.php/$1;
              #若是子目录则使用下面这句,将subdir改成目录名称即可。
              #rewrite ^/subdir/(.*)$ /subdir/index.php/$1;
            }
            
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ \.php(.*)$  {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_split_path_info  ^((?U).+\.php)(/?.+)$;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            fastcgi_param  PATH_INFO  $fastcgi_path_info;
            fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;
            include        fastcgi_params;
        }
        
        

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }

编辑Nginx配置文件 一般在 /etc/nginx/conf.d 目录下 红色部分按如上配置

posted @ 2016-02-11 16:20  思如雨  阅读(3824)  评论(0编辑  收藏  举报