【问题标题】:Set multiple Index file for Apache server为 Apache 服务器设置多个索引文件
【发布时间】:2019-08-29 10:12:20
【问题描述】:

我想设置多个索引文件,但不强制。 让我更好地解释一下,如果用户提出以下请求: mydomain.org -> mydomain.org/default.php

default.php

<?php
    header("location: /old");
?>

如果提出以下请求: mydomain.org/index.php -> mydomain.org/index.php(它不需要改变任何东西)

我通过以下方式设置.htaccess文件:

DirectoryIndex default.php index.php

但如果我尝试提出以下请求: mydomain.org/index.php -> mydomain.org/default.php

附言在服务器的根目录中有 Wordpress 中的新站点(正在进行中),而在“旧”文件夹中有旧站点(不是 wordpress)

【问题讨论】:

    标签: php wordpress apache .htaccess directoryindex


    【解决方案1】:

    我的问题解决了,.htaccess文件的配置是正确的。 问题隐藏在 Wordpress 的“index.php”文件中,该文件重定向到“/”。

    为了禁用此重定向,我将以下代码添加到 wp-settings.php 文件中:

    add_filter ('redirect_canonical', function ($redirect_url, $requested_url) {
        if ($requested_url == home_url ('index.php')) {
            return '';
        }
    }, 10, 2);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-09-02
      • 2020-03-16
      • 2013-02-28
      • 2021-06-23
      • 2011-08-17
      • 2016-03-29
      • 2023-03-24
      • 1970-01-01
      相关资源
      最近更新 更多