帮我看下我的NGINX配置,PHP文件有的还会下载不返回404
系统版本:系统:centOS7.9 NGINX:1.16
问题描述:
location / {
# 不是文件也不是文件夹,重写规则
if (!-e $request_filename){
rewrite^(.*)$/index.php?s=$1last;
break;
}
# 根目录只开放index.php、robots.txt
if ($uri ~* ^/(index\.php|robots\.txt)) {
break;
}
# 只输入域名也能访问到默认的index.php
location ~ ^/$ {
break;
}
# 开放图标文件
location ~ ^/favicon.ico {
break;
}
# 禁止根目录访问文件,这里不这样配置,能访问到根目录的图片文件,不知道为什么
location ~ ^/.*\.(gif|jpg|jpeg|png|bmp|swf)$ {
deny all;
return 403;
}
#其他全部拒绝;
return 404;
}
# 禁止访问多个目录下所有文件
location ~ /(application|config|extend|route|runtime|thinkphp|vendor)/ {
deny all;
return 403;
}
# 禁止访问public目录下的 php文件
location /public {
location ~* \.(php|sh|pl|py)$ {
deny all;
return 403;
}
}
当我访问 http://127.0.0.1/public/config.php PHP文件会被下载下来,个别又会返回403,不知道什么原因
相关截图(日志、错误):
同问正确应该怎么配置啊
页:
[1]