【问题标题】:Is it necessary to set [DirectoryIndex] while not using index.php?不使用index.php时是否需要设置[DirectoryIndex]?
【发布时间】:2011-07-05 09:37:46
【问题描述】:

我的站点根访问权限由 htaccess 管理:它将各种别名重定向到他们自己的主文件 /en/home 用于英语 /de/home 用于德语等。以前,我使用 index.php 来路由和重定向所有这些,因此 DirectoryIndex 有这样的东西:

DirectoryIndex /index.php

不过现在还没有index.php文件,所以我注释掉了

# DirectoryIndex /index.php

取消注释并将其设置为默认 /en/home 会更好吗(有或没有 .php,因为在这种情况下?我已经设置了规则,因此我的浏览器中的页面在没有给出扩展名时也可以工作)

DirectoryIndex /en/home

在上述所有情况下,我的网站都可以正常工作,当我设置上述三个实例中的任何一个时,我看不到任何变化。但是……“一定有一个最好的,不是吗?”

谢谢!

【问题讨论】:

    标签: apache .htaccess apache2 directory indexing


    【解决方案1】:

    如果你有写在 .htaccess 中的规则,最好不要在你使用的任何 php 配置和路由函数中重复这些规则。通过 apache(您的 .htaccess)路由比通过 php 颠覆路由要快得多,尽管如果没有大量流量,您将无法实现收益。

    【讨论】:

    • 这是否意味着我可以继续删除整个 DIrectoryIndex 行,因为 301 重定向已经到位,无论如何都会将人们带到正确的文件?
    猜你喜欢
    • 2020-11-20
    • 1970-01-01
    • 2019-10-19
    • 1970-01-01
    • 1970-01-01
    • 2015-07-12
    • 2018-07-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多