如何让 Apache 提供 index.php 而不是 index.html? [英] How to make Apache serve index.php instead of index.html?

查看:36
本文介绍了如何让 Apache 提供 index.php 而不是 index.html?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我把下面这行放在 index.html 文件中,让 Apache 包含 index.php 文件:

If I put the following line in a index.html file, to make Apache include the index.php file:

  <?php include("/Live/ls_client/index.php"); ?>    

访问 index.html 页面显示:

<!--?php include("/Live/ls_client/index.php"); ?-->

这是为什么?为什么它实际上不包含 PHP 文件?

Why is that? Why doesn't it actually include the PHP file?

推荐答案

正如其他人所指出的,很可能您没有设置 .html 来处理 php 代码.

As others have noted, most likely you don't have .html set up to handle php code.

话虽如此,如果您所做的只是使用 index.html 来包含 index.php,那么您的问题可能应该是我如何使用 index.php 作为索引文档?

Having said that, if all you're doing is using index.html to include index.php, your question should probably be 'how do I use index.php as index document?

在这种情况下,对于 Apache (httpd.conf),搜索 DirectoryIndex 并用此替换该行(只有在启用 dir_module 时才有效,但那是大多数安装默认):

In which case, for Apache (httpd.conf), search for DirectoryIndex and replace the line with this (will only work if you have dir_module enabled, but that's default on most installs):

DirectoryIndex index.php

如果您使用其他目录索引,请按优先顺序列出它们,即

If you use other directory indexes, list them in order of preference i.e.

DirectoryIndex index.php index.phtml index.html index.htm

这篇关于如何让 Apache 提供 index.php 而不是 index.html?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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