Apache下,*.php.rar格式的文件被当成php执行?

Susan Sarandon
Release: 2016-05-19 14:05:35
Original
879 people have browsed it

一直以来都觉得.rar格式的文件被访问的话,会以附件的方式打开。但是*.php.rar这种格式的文件呢?
我今天试了一下。apache居然把它当成php来执行了。为什么会这样呢?

原来,每遇到一种后双重后缀名(如xxx.php.rar)的文件,Apache都会去conf/mime.types 文件中检查最后一个后缀, 如果最后一个后缀并没有在mime.types文件中定义, 则使用前一个后缀来解释 , 因为在默认情况下,rar并未在mime.types中定义, 故Apache会使用php后缀来解释文件。

我们知道,一般网站服务器都会开放rar附件上传,并可能保留原来文件名称。这样一来,服务器就存在很大的安全隐患了。

既然我们发现了问题,那么如何让apache将*.php.rar的文件就当作附件来执行呢?
1.修改mime.types文件,在最后面加一条:
application/rar       rar
然后重新启动Apache,即可

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!