nginx根据扩展名限制程序和文件访问禁止访问php? 发布时间:2024/12/07 nginx根据扩展名限制程序和文件访问禁止访问php?下面编程教程网小编给大家详细介绍一下具体代码! nginx配置如下: server { listen 80; server_name www.ipkd.cn; location / { root html; index index.php index.html index.htm; } location ~ ^/images/.*\.(php|php5|sh|pl|py)$ { deny all; } location ~ ^/static/.*\.(php|php5|sh|pl|py)$ { deny all; } location ~ ^/data/(attachment|avatar).*\.(php|php5)$ { deny all; } //禁止访问*.txt和*.doc文件 location ~* \.(txt|doc)$ { if (-f $request_filename) { root /data/www/www; #rewrite ... #可以重定向到某个URL; break; } } location ~* \.(txt|doc)$ { root /data/www/www; deny all; } } 复制代码 以上是编程学习网小编为您介绍的“nginx根据扩展名限制程序和文件访问禁止访问php?”的全面内容,想了解更多关于 php入门 内容,请继续关注编程基础学习网。