【问题标题】:htaccess change DirectoryIndex priority to php and not htmlhtaccess 将 DirectoryIndex 优先级更改为 php 而不是 html
【发布时间】:2011-06-30 06:52:51
【问题描述】:
  1. 在生产服务器中有 index.html 和 index.php
  2. 默认情况下会加载 index.html。
  3. 我希望 index.php 成为要加载的默认脚本,如果 index.php 不存在,则可以加载 index.html。
  4. 这是一个共享主机,所以我们无法访问 httpd.conf 文件
  5. 所以我想创建 .htaccess 文件来满足上述条件。

    在 .htaccess 文件中包含的指令是什么?

另外,我在这里解释一下上面的原因。

  1. php 项目是在codeigniter 框架中完成的。
  2. 在我们有 oscommerce 的根目录的子文件夹中。
  3. 我们没有任何 index.html,只有 index.php 存在。
  4. index.html 会定期通过某种方式创建,其中包含 iframe 代码。
  5. 客户端报告此问题,我们不断删除 index.html 文件
  6. 我们也更改了 ftp 密码。
  7. 所以我认为临时解决方案是让 index.php 作为默认加载而不是 index.html

【问题讨论】:

    标签: apache .htaccess


    【解决方案1】:

    根据Apache documentation for DirectoryIndex,只需将以下内容放在与index.php相同目录下的.htaccess文件中:

    DirectoryIndex index.php index.html
    

    【讨论】:

    • 在我的 htaccess 文件中,如何更改 apache 服务器正在查找的文件目录?在 GoDaddy 主机上,我将 DirectoryIndex my-project/public/index.php 放入 .htaccess 但它不起作用
    • @Growler 这将在 Apache 配置中。如果您不控制 Apache,那么您将不得不使用您的虚拟主机。
    【解决方案2】:

    DirectoryIndex index.php index.html

    【讨论】:

      【解决方案3】:

      这取决于 Apache 目录索引配置。您可以根据需要对其进行自定义:

      DirectoryIndex index.html index.shtml index.php index.htm 
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-06-15
        • 2012-02-24
        • 1970-01-01
        • 2021-03-06
        相关资源
        最近更新 更多