nginx 支持pathinfo

2019-03-06  本文已影响0人  大史叔叔

查看nginx.conf的路径

$ nginx -t

nginx: the configuration file /usr/local/etc/nginx/nginx.conf syntax is ok
nginx: configuration file /usr/local/etc/nginx/nginx.conf test is successful

编辑nginx.conf文件,修改以下两处

$ vim /usr/local/etc/nginx/nginx.conf

location / {
            if (!-e $request_filename) {
                rewrite  ^/(.*)$  /index.php/$1  last;
                break;
            }
        }
location ~ [^/]\.php(/|$){

            root           /usr/local/var/www/tp5/public/;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;

            include        fastcgi_params;

            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 PATH_INFO       $path_info;
            fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;
            fastcgi_param SCRIPT_NAME     $real_script_name;

        }
上一篇下一篇

猜你喜欢

热点阅读