Home  >  Article  >  Backend Development  >  nginx如何禁止文件上传目录执行PHP

nginx如何禁止文件上传目录执行PHP

WBOY
WBOYOriginal
2016-06-06 20:32:001379browse

/1/userheadimg_files
为图像等文件上传文件夹,如何禁止这个目录下的PHP文件等被解析执行。

可能表述的不清楚.

回复内容:

/1/userheadimg_files
为图像等文件上传文件夹,如何禁止这个目录下的PHP文件等被解析执行。

可能表述的不清楚.

<code>location ~ \/1\/userheadimg_files\/.*\.php {
    deny all;
}
</code>

<code>location ^~ /1/userheadimg_files {
    deny all;
}
</code>

<code>location ~ /upload/.*\.php$ { deny all; } 禁止访问/upload下的PHP文件.
或者
location ~ \.php$ {} 中加入 if ($uri !~ "^/upload/") { fastcgi_pass 127.0.0.1:9000; } 不解析/upload下的PHP文件.
</code>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn