【问题标题】:Change default page from index.php to index.html将默认页面从 index.php 更改为 index.html
【发布时间】:2016-10-25 10:04:03
【问题描述】:

就像问题一样简单。我想将我网站的默认页面从index.php 更改为index.html。我不知道我的服务器(000webhost.com,网站正在开发中)是否使用 Apache,但我更改了 .htaccess 文件,并添加了 DirectoryIndex index.html index.php。不过还是不行。

当网站加载时,它会加载 randomwebsitename12345.com。如果我将 /index.html 添加到字符串中,则页面加载正常,应该如此。如果我从服务器中删除 .php 文件,则网站会加载 index.html。

有什么想法吗?

【问题讨论】:

  • 你有2个DirectoryIndexs吗?查看请求的响应标头,服务器版本可能在其中。

标签: php html .htaccess


【解决方案1】:

为什么不直接从.htaccess 文件中删除index.php

【讨论】:

  • 我一开始没有,后来加了看看有没有什么区别。没有,所以我离开了。
  • 很公平。另一种选择是将index.php 文件重命名为index以外的其他名称
  • 知道一个替代方案还是不错的,但现在就可以了!
【解决方案2】:

您可以使用以下重写规则将 index.html 设置为您的主页:

在您的 htaccess 中的其他规则之前添加它:

RewriteEngine on


RewriteRule ^$ /index.html [L]

【讨论】:

  • 没用 :(。这是我的 .htaccess 文件中的内容:RewriteEngine on RewriteRule ^$ /index.html [L] DirectoryIndex index.html index.php
  • 删除 DirectoryIndex 指令。
猜你喜欢
  • 2013-11-22
  • 2014-05-04
  • 2012-12-20
  • 2013-03-24
  • 2015-02-19
  • 2023-04-01
  • 2013-05-13
  • 1970-01-01
  • 2011-10-17
相关资源
最近更新 更多