宝塔724运维节来了,企业版999元/年,送安全巡检;证书组队,低至28元!查看活动
当前位置:论坛首页 > Linux面板 > 求助

【已回应】Nginx环境使用location后php无法解析,打开变成下载

发表在 Linux面板2020-5-16 14:57 [复制链接] 4 2115

环境:Centos7.5+Nginx 1.16+PHP7.4+MYSQL5.6
问题一:URL无论怎么修改都无法不区分大小写;
问题二:使用location后php无法解析,打开变成下载;

求大神帮忙看一下,谢谢!

Nginx 网站规则如下:

server {
    listen 80;
    server_name 域名;

        location ~ \/(upload|audio).*\.(mp3|jpeg|jpg|png|gif|csv)$ {
                root /data/web/backend/public;
                expires 7d;
        }

        location /dist {

                root /data/web/adm;
                index index.html;

                location ~ .*\.(html|htm)$ {
                        expires 7d;
                }
        }

        location / {
               
                root /data/web/backend/www/adm;
                index index.php index.html;
                if (!-e $request_filename) {
                        rewrite ^/(.*)$ /index.php?_url=/$1 last;
                }

                client_max_body_size 3m;

                location ~\.php$ {
                        fastcgi_pass  127.0.0.1:9000;
                        fastcgi_index index.php;
                        include fastcgi_params;
                        fastcgi_split_path_info   ^(.+\.php)(/.+)$;
                        fastcgi_param PATH_INFO   $fastcgi_path_info;
                        fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
                        fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
                }
        }

}
server {
    listen 80;
    server_name  域名;
        
        location ~ \/upload.*\.(jpeg|jpg|png|gif)$ {
                root /data/web/backend/public;
                expires 1d;
        }

        location /dist {

                root /data/web/h5;
                index index.html;

                location ~ .*\.(html|htm)$ {
                        expires 1s;
                }
        }

        location / {

                root /data/web/backend/www/web;
                index index.php index.html;
                if (!-e $request_filename) {
                        rewrite ^/(.*)$ /index.php?_url=/$1 last;
                }


                location ~\.php$ {
                        fastcgi_pass  127.0.0.1:9000;
                        fastcgi_index index.php;
                        include fastcgi_params;
                        fastcgi_split_path_info   ^(.+\.php)(/.+)$;
                        fastcgi_param PATH_INFO   $fastcgi_path_info;
                        fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
                        fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
                }
        }        
}

使用道具 举报 只看该作者 回复
发表于 2020-5-16 15:06:22 | 显示全部楼层
使用道具 举报 回复 支持 反对
发表于 2020-5-16 15:08:17 | 显示全部楼层
您好,这不是面板上默认的配置文件,自己做的修改的话,规则错误自己排查。
nginx区分大小写:
location ~*  /目录名称 {

}
使用道具 举报 回复 支持 反对
发表于 2020-5-16 15:15:10 | 显示全部楼层
zuantou 发表于 2020-5-16 15:06
参考这个https://blog.csdn.net/qq_33101675/article/details/78113356
反向操作下看看

虽然没有解决问题,不过还是非常感谢您!
使用道具 举报 回复 支持 反对
发表于 2020-5-16 15:17:28 | 显示全部楼层
大炮运维V587 发表于 2020-5-16 15:08
您好,这不是面板上默认的配置文件,自己做的修改的话,规则错误自己排查。
nginx区分大小写:
location ~* ...

已加您QQ,麻烦通过一下,谢谢!
使用道具 举报 回复 支持 反对
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

普通问题处理

论坛响应时间:72小时

问题处理方式:排队(仅解答)

工作时间:白班:9:00 - 18:00

紧急运维服务

响应时间:3分钟

问题处理方式:宝塔专家1对1服务

工作时间:工作日:9:00 - 18:30

宝塔专业团队为您解决服务器疑难问题

点击联系技术免费分析

工作时间:09:00至18:30

快速回复 返回顶部 返回列表