php - 如何让 Apache 服务 index.php 而不是 index.html?

标签 php apache include

如果我将以下行放在 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/

相关文章:

php - 检测文件中的空行

mysql - Kontakt ibeacon 的 RSSI 统计设置为 Eddystone 格式

c# - C# 的 SystemParametersInfo 参数定义

php - 在 Eloquent 模型中返回集合而不是关系

php - 拆分两个不同数据库表中的多行

apache - 在 Apache Server mod_proxy 指令中为所有 ProxyPass 映射设置超时

java - 使用括号中的 JSON 值查询 Apache Solr

c++ - 函数的多重定义,为什么守卫没有捕获这个?

c++ - 如何包含来自另一个文件夹的文件?

php - 在 Centos 6.5 上安装 Mycrypt