【问题标题】:REQUEST_URI is populated with default-file (DirectoryIndex) /index.htmlREQUEST_URI 填充有默认文件 (DirectoryIndex) /index.html
【发布时间】:2019-06-23 12:53:28
【问题描述】:

在使用 Centos 迁移到新服务器后,一些行为发生了变化。

当获取http://example.com 时,环境变量REQUEST_URI 包含“/index.html”(没有index.html)。

我希望:

在获取http://example.com 时,REQUEST_URI 为“/”。

在获取http://example.com/index.html 时,REQUEST_URI 为“/index.html”。

这会影响我的 .htaccess(重写器对“index.html”而不是“空字符串”做出反应)以及我的脚本 (Perl $ENV{'REQUEST_URI'})

当只获取http://example.com 时,如何让REQUEST_URI 填充'/'?

【问题讨论】:

    标签: apache request-uri directoryindex


    【解决方案1】:

    尝试禁用 DirectoryIndex 和 MultiViews,将其放在 .htaccess 的顶部:

    DirectoryIndex disabled
    Options -MultiViews
    

    【讨论】:

    • 抱歉,这不起作用。同样,当我从目录中删除 index.html 时,我得到 403 Forbidden。
    【解决方案2】:

    似乎该问题仅在 Plesk 'Hosting settings' PHP Support 设置为

    时出现

    '将 PHP 作为 nginx 服务的 FPM 应用程序运行'

    当我把它改成

    '将 PHP 作为 Apache 服务的 FPM 应用程序运行' 要么 '将 PHP 作为 Apache 服务的 FastCGI 应用程序运行'

    没有问题。

    【讨论】:

      猜你喜欢
      • 2013-11-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-06-23
      • 1970-01-01
      • 2016-03-28
      • 2012-07-22
      • 2020-06-02
      相关资源
      最近更新 更多