繁体   English   中英

Apache executes code in files that have.php prepended before extension ex: .php.txt, php.pdf

[英]Apache executes code in files that have .php prepended before extension ex: .php.txt , php.pdf

What can i do to stop Apache execute code in files that have.php prepended before extension ex: .php.txt, php.pdf, i do not know if this is related to webuzo admin panel n/or apache in general?

Apache 版本 2.2.34

在webuzo论坛上打开线程,如果其他人有这个问题,它可能是相关的: https://www.softaculous.com/board/index.php?tid=17642

这是相当标准的行为 -文件可以在 Apache 上具有多个扩展名 (就像在其他操作系统/文件系统上一样。)

但是,可以避免这种行为。

Whether files that end in .php.txt or .php.pdf are processed for PHP is dependent on how PHP is enabled on the server.

例如,如果您简单地使用AddHandler ,则任何包含.php扩展名的文件(如.php.txt )都将由 PHP 处理程序处理:

AddHandler application/x-httpd-php .php

但是,如果您仅在特定文件模式上调用SetHandler ,即。 .php出现在文件名的末尾时,可以避免这种行为。

<FilesMatch "\.php$">
    SetHandler application/x-httpd-php
</FilesMatch>

注意:这不是复制/粘贴解决方案 - 它实际上取决于 PHP 在 Apache web 服务器上的实现方式。

根据您的要求,您可能会阻止对包含.php扩展名但不在 URL 路径末尾的文件的请求。 例如:

<FilesMatch "\.php\.">
    Order Allow,Deny
    Deny from all
</FilesMatch>

注意:这是 Apache 2.2 语法(如问题中所述)。 如果您使用的是 Apache 2.4,那么您将使用Require all denied而不是最后一个块中的OrderDeny指令。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM