【问题标题】:How to set default index page by .htaccess only in root folder如何仅在根文件夹中通过 .htaccess 设置默认索引页
【发布时间】:2018-02-15 10:32:48
【问题描述】:

我创建了一个 .htaccess 文件来将默认 index.html 页面设置为仅在根文件夹中的 homepage.php。

我已经通过添加 DirectoryIndex homepage.php index.html 进行了检查,但这也适用于所有文件夹索引页面。

任何机构都知道如何排序?

【问题讨论】:

  • 将您的 .htaccess 文件添加到您的帖子中可以让人们提供带有解释的更新版本。

标签: .htaccess mod-rewrite


【解决方案1】:

在您的站点根目录.htaccess 中使用mod_rewrite 规则而不是DirectoryIndex

RewriteEngine On

RewriteRule ^(index\.html)?$ homepage.php [L,NX]

这将为您网站的登录页面加载homepage.php

【讨论】:

  • 哇,感谢您的帮助,我发现这段代码非常适合我RewriteRule ^index.html$ homepage.php
  • 我在互联网上搜索此解决方案link
  • 我发布了一个明确提到使用 mod_rewrite 的答案,这就是您最终搜索的内容,但无论如何这是您的电话。
  • 你能帮我在 html 文件中使用 php 脚本吗?我已经在godaddy中使用了AddType application/x-httpd-php .html .htm它在godaddy中的工作,但是这段代码在whois服务器中不起作用。
  • 是的,我可以尝试回答这将是一个不同的问题,您应该单独发布。 SO 管理员不鼓励从 cmets 部分提出新问题。
猜你喜欢
  • 2012-01-25
  • 2014-02-21
  • 1970-01-01
  • 1970-01-01
  • 2015-09-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2010-12-27
相关资源
最近更新 更多