【问题标题】:htaccess rule to make index.php be served instead of index.html when go to http://localhosthtaccess 规则以在访问 http://localhost 时提供 index.php 而不是 index.html
【发布时间】:2012-03-11 06:26:30
【问题描述】:

谁能提供一个 .htaccess 规则,让我的 index.php 覆盖我的 index.html?

这意味着当我转到 http://localhost 时会提供 index.php 而不是 index.html。

【问题讨论】:

    标签: .htaccess xampp localhost


    【解决方案1】:

    这样就可以了:

    DirectoryIndex index.php index.html
    

    如果没有 index.php,则将提供 index.html 文件。

    【讨论】:

    • 这是正确的做法。如果迁移一个可能有指向 index.html 的显式链接的站点,那么也要执行 RewriteRule。
    【解决方案2】:

    这可能会起作用...

    RewriteEngine On
    RewriteBase /
    RewriteRule ^index.html$ index.php [R=301,L]
    

    【讨论】:

      【解决方案3】:

      在 apache 配置文件(或 .htaccess)中,将 DirectoryIndex 设置为 index.php,而不是 index.html

      这是一个例子: http://www.javascriptkit.com/howto/htaccess6.shtml

      【讨论】:

        猜你喜欢
        • 2018-01-17
        • 2012-12-21
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-09-26
        • 1970-01-01
        • 2019-05-01
        • 1970-01-01
        相关资源
        最近更新 更多