【问题标题】:How to change the default index.html to index.php when you have two index files有两个索引文件时如何将默认 index.html 更改为 index.php
【发布时间】:2012-12-20 02:27:39
【问题描述】:

我想要两个索引文件。一 - index.php 和一 - index.html。 但我也想在服务器上制作默认文件 - index.php (我在本地环境中有两个文件)。 我已经尝试在 .htaccess 行中添加: DirectoryIndex index.php 但 index.html 仍然首先加载。 有没有不删除其中一个文件的解决方案。

【问题讨论】:

  • 这听起来像是在某处引起混淆?为什么要两个“索引”页面?

标签: .htaccess


【解决方案1】:

您可以指定多个值:

DirectoryIndex index.php index.html

为了让它工作,您需要允许覆盖 apache 配置中的索引

AllowOverride indexes

http://httpd.apache.org/docs/2.2/mod/mod_dir.html

一个常见错误是您的 .htaccess 文件根本没有被读取。确保您的 .htaccess 被读取的一个好方法是在其中输入一个错字并确保您得到一个错误。

【讨论】:

  • 很久之后我回到这个问题。感谢您的回答,这是有价值的信息,非常有帮助。我只想为接下来的内容添加以确保在本地环境中将主机 127.0.0.1 www.example.com 添加到主机文件,然后重新启动 apache
猜你喜欢
  • 1970-01-01
  • 2013-11-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-09-01
  • 2016-01-25
  • 2022-01-27
相关资源
最近更新 更多