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入门 内容,请继续关注编程基础学习网。
沃梦达教程
本文标题为:nginx根据扩展名限制程序和文件访问禁止访问php?
猜你喜欢
- PHP+Session防止表单重复提交的解决方法 2022-10-12
- PHP检查文件是否存在,不存在自动创建及读取文件内容操作示例 2023-03-19
- PHP中利用substr_replace将指定两位置之间的字符替换为*号 2024-02-19
- 如何使用PHP依赖管理工具Composer 2022-09-01
- PHP使用PDO 连接与连接管理操作实例分析 2023-04-08
- PHP中unset,array_splice删除数组中元素的区别 2024-01-01
- php创建类并调用的实例方法 2023-12-12
- 实例讲解PHP表单 2023-04-20
- JSON用法之将PHP数组转JS数组,JS如何接收PHP数组 2024-01-12
- PHP实现将颜色hex值转换成rgb的方法 2024-04-12