为什么Apache的执行.php.html文件作为PHP? [英] Why is Apache executing .php.html files as PHP?

查看:145
本文介绍了为什么Apache的执行.php.html文件作为PHP?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个奇怪的问题......我使用的文档生成器产生了很多像文档/ foo.php.html输出。这是XHTML,因此包含&LT; XML ...&GT; 在文件开头的标签。问题是,阿帕奇已经在某种程度上决定通过PHP间preTER来运行它,即使的.php出现在文件名的中间,而不是结尾。这反过来又触发一个PHP错误,因为它看到&LT; 的命令开始执行PHP code,并立即得到了<$困惑C $ C> XML ... 跟随其后。

I have an odd problem...I'm using a documentation generator which generates a lot of output like docs/foo.php.html. It's XHTML, and thus contains <?xml...> tags at the beginning of file. The problem is, Apache has somehow decided to run it through the PHP interpreter, even though ".php" appears in the middle of the filename, and not at the end. This in turn triggers a PHP error, because it sees "<?" as the command to start executing PHP code, and immediately gets confused by the "xml..." which follows it.

我如何配置Apache只执行.php文件,而不是.php.html文件?字符串php.html没有出现在我的Apache的配置文件明确的任何地方。有一条线 AddHandler的PHP5脚本的.php ,但我看不出这也将包括.php.html文件。

How do I configure Apache to ONLY execute .php files, and not .php.html files? The string "php.html" does not appear explicitly anywhere in my Apache config files. There is a line "AddHandler php5-script .php", but I don't see how that would also include ".php.html" files.

推荐答案

这个问题似乎是在 mod_mime

从Apache mod_mime文档页面引用:

Quote from the Apache mod_mime documentation page:

如果您将映射到一个特定的一段元数据preFER只有文件名的最后一个点分隔的一部分,那么不要使用添加*指令。例如,如果你想拥有处理为CGI脚本文件foo.html.cgi,而不是文件bar.cgi.html,然后而是采用AddHandler的CGI脚本的CGI,使用

If you would prefer only the last dot-separated part of the filename to be mapped to a particular piece of meta-data, then do not use the Add* directives. For example, if you wish to have the file foo.html.cgi processed as a CGI script, but not the file bar.cgi.html, then instead of using AddHandler cgi-script .cgi, use

&LT; FilesMatch \\ $名为.cgi GT&;

SetHandler CGI脚本

&LT; / FilesMatch&GT;

此外,您还可以谷歌 Apache的mod_mime多个扩展名

这篇关于为什么Apache的执行.php.html文件作为PHP?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆