【问题标题】:Why DirectoryIndex index.php index.html is not working?为什么 DirectoryIndex index.php index.html 不起作用?
【发布时间】:2015-07-12 15:08:50
【问题描述】:

我目前使用 ipage 作为主机,并且有一个指向 index.html 的域。但是,我需要域指向 index.php。所以我创建了一个 .htaccess 并且只写了; DirectoryIndex index.php index.html 并保存了它,但它不起作用,用户仍被定向到 index.html。有一个问题,index.php 位于名为“SourceFolder”的文件夹中。所以我认为服务器寻找 index.php 并找不到它。

【问题讨论】:

    标签: php html .htaccess mod-rewrite server


    【解决方案1】:

    您的 DirectoryIndex 指令很好,但您需要将请求路由到正确的文件夹。

    在根 .htaccess 中有此代码:

    DirectoryIndex index.php index.html
    
    RewriteEngine On
    
    RewriteRule !^SourceFolder/ SourceFolder%{REQUEST_URI} [L,NC]
    

    【讨论】:

      【解决方案2】:

      所以你网站的默认“根”目录中有一个名为 SourceFolder 的文件夹,并且 index.php 文件在其中?

      如果是这样,那么只需在 htaccess 中执行以下操作。

      DirectoryIndex SourceFolder/index.php
      

      这将在 SourceFolder 中查找 index.php。

      【讨论】:

        猜你喜欢
        • 2021-05-23
        • 2011-12-13
        • 2014-06-24
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-01-01
        • 2011-06-22
        相关资源
        最近更新 更多