【问题标题】:.htaccess- How to make index.php and index.html work together?.htaccess- 如何让 index.php 和 index.html 一起工作?
【发布时间】:2011-06-22 20:25:45
【问题描述】:

我正在尝试使我的 .htaccess 工作。我的 DirectoryIndex 是 index.html

我希望访问者在访问 www.domain.com 时看到 index.html。当访问者访问 www.domain.com/index.php 时,我还希望 index.php 能够正常工作。

正在发生的事情是访问者访问 www.domain.com/index.php 并且他们被重定向到 www.domain.com 以便他们看到 index.html 。有没有办法让 www.domain.com/index.php 转到 index.php 页面而不是转到根目录。

我尝试了 RewriteCond %{THE_REQUEST} 和 RewriteCond %{REQUEST_URI},但没有成功。

感谢您的帮助! :)

【问题讨论】:

  • 其实,你想要的行为是默认的。查看其他配置设置,如果有干扰(最可能是 RewriteRules)。

标签: .htaccess


【解决方案1】:

从 DirectoryIndex 指令列表中删除 index.php(正如您所做的那样)应该可以理想地解决这个问题。

DirectoryIndex index.html

【讨论】:

  • 您好 Adarsh,感谢您的回答。当我从 DirectoryIndex 中删除 index.php 并转到 index.php 时,.htaccess 会加载 index.html,因为它重定向到 domain.com
  • 表示某些东西正在阻止 index.php 从索引文件列表中删除。
  • 我明白了,谢谢...我可以使用 .htaccess 进行更改,还是应该联系我的托管公司?
  • 如果主 httpd.conf 的 DirectoryIndex 设置允许使用 AllowOverride 指令进行覆盖,您应该能够使用 .htaccess 进行更改。否则,除了联系您的托管公司之外别无他法。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-01-13
  • 1970-01-01
  • 1970-01-01
  • 2014-09-19
  • 2011-07-31
  • 2013-04-18
相关资源
最近更新 更多