如果我将以下行放在 index.html
文件中,以使 Apache 包含 index.php
文件:
<?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 - 如何让 Apache 服务 index.php 而不是 index.html?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16192049/