Nginx下ThinkPHP伪静态隐藏index.php解决重定向次数过多

5746

# 注意:自行修改root和server_name

server {

        listen       80;

        root /www/web/feibao_xxx_com/public_html;

        server_name feibao.xxx.com;

        index  index.html index.php index.htm;

        error_page  400 /errpage/400.html;

        error_page  403 /errpage/403.html;

        error_page  404 /errpage/404.html;

        error_page  503 /errpage/503.html;

        location ~ \.php(.*)$ {

            fastcgi_pass  unix:/tmp/php-70-cgi.sock;

            fastcgi_index  index.php;

            #fastcgi_param  SCRIPT_FILENAME  $DOCUMENT_ROOT$fastcgi_script_name;

            #fastcgi_param PATH_INFO $2;

            include fcgi.conf;

            set $real_script_name $fastcgi_script_name;

            set $path_info "";

            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;

        }

        location ~ /\.ht {

            deny  all;

        }

        location / {

            if (!-e $request_filename) {

               rewrite  ^/(.*)$  /index.php/$1  last;

               break;

            }

            try_files $uri $uri/ /?$args;

        }

}

原文:https://blog.csdn.net/hd2killers/article/details/83657316