Parminder Singh
Parminder Singh

Reputation: 352

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

p.s. 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)

Upvotes: -1

Views: 1581

Answers (1)

Parminder Singh
Parminder Singh

Reputation: 352

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);

Upvotes: 0

Related Questions