简体   繁体   中英

Set multiple Index file for Apache server

I want to set multiple index files, but without forcing. Let me explain better, if the user makes the following request: mydomain.org -> mydomain.org/default.php

default.php

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

If the following request is made: mydomain.org/index.php -> mydomain.org/index.php (it doesn't have to change anything)

I set the .htaccess file in the following way:

DirectoryIndex default.php index.php

but if I try to make the following request: mydomain.org/index.php -> mydomain.org/default.php

ps In the root of the server there is the new site in Wordpress (work in progress), while in the "old" folder there is the old site (not wordpress)

I solved my problem, the configuration of the .htaccess file is correct. The problem was hidden in Wordpress's " index.php " file, which redirects to "/".

To disable this redirect I added the following code into the wp-settings.php file:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM