如果我把下面一行在index.html
文件,以让Apache包括index.php
文件:如何让Apache服务于index.php而不是index.html?
<?php include("/Live/ls_client/index.php"); ?>
参观index.html
页面显示我:
<!--?php include("/Live/ls_client/index.php"); ?-->
这是为什么?为什么它实际上不包含PHP文件?
如果我把下面一行在index.html
文件,以让Apache包括index.php
文件:如何让Apache服务于index.php而不是index.html?
<?php include("/Live/ls_client/index.php"); ?>
参观index.html
页面显示我:
<!--?php include("/Live/ls_client/index.php"); ?-->
这是为什么?为什么它实际上不包含PHP文件?
正如其他人所指出的,很可能您没有设置.html
来处理php代码。
话虽如此,如果您所做的只是使用index.html
来包含index.php
,您的问题可能应该是'我如何使用index.php
作为索引文件?
在这种情况下,为Apache(httpd.conf文件),搜索DirectoryIndex
和替换该行(如果你有dir_module
启用只会工作,但是这是在默认安装大部分):
DirectoryIndex index.php
如果使用其他目录索引,列出它们的优先顺序即
DirectoryIndex index.php index.phtml index.html index.htm
PHP只能在.php
文件扩展名上使用。
如果您使用的是Apache,则还可以在您的httpd.conf
文件中设置PHP扩展。你必须找到行:
AddType application/x-httpd-php .php .html
^^^^^
,并添加多少扩展,这应该与PHP解释器,只要你想读。
虽然你可以* *添加'.html'扩展到PHP处理程序在你的Apache配置 – 2013-04-24 12:30:59
OK , 我会尝试。 thx – 2013-04-24 12:31:44
@dirt,right,added。 – Shoe 2013-04-24 12:33:07
截至今天(2015年8月,第1),Apache2
在Debian Jessie
,你需要编辑:
[email protected]:/etc/apache2/mods-enabled$ vi dir.conf
,并更改该行的顺序,把index.php的第一位置:
DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm
你也可以使用'DirectoryIndex index.php index.html' - 如果这些在一台服务器上混合使用,则很有用。 – MarioP 2013-04-24 12:52:36
编辑该文件。 – 2013-04-24 12:57:06
work!,谢谢:) – 2013-04-24 13:12:29