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
.htaccessfile:When
index.phpexists, it's used. Otherwise,index2.phpis used.When
index.phpandindex2.phpexist,index.phpis used, because it appeared first.See also: Apache Docs > DirectoryIndex directive.