I have installed two CMSs in the same directory. One of the CMSs allows the index.php file to be renamed to index2.php, the other one does not. Ideally I'd like to set up a conditional rule in the .htaccess file which:
- Uses index.php as the default DirectoryIndex
- If there is a 404 error then set the DirectoryIndex to index2.php
Does anyone know if/how this possible?
(404 = File Not Found), so you're actually looking for a method which allows going through a list of possible index files)
Add the following line to your
.htaccess
file:When
index.php
exists, it's used. Otherwise,index2.php
is used.When
index.php
andindex2.php
exist,index.php
is used, because it appeared first.See also: Apache Docs > DirectoryIndex directive.