Search code examples
.htaccessrecursiondirectoryindex

Can I declare the DirectoryIndex In .htaccess Non-recursively?


In my /httpdocs/ folder I need to change the filename of index.php. I did this by writing a new line to my .htaccess file:

DirectoryIndex index2.php

However, it seems that all subfolders under /httpdocs/ were looking for index2.php for their DirectoryIndex file. Is there a way I can alter the DirectoryIndex file for my /httpdocs/ folder without it recursively affecting every folder under it?


Solution

  • You could try this...

    DirectoryIndex index2.php index.php index.html
    

    Apache will look from left to right for the index file.

    For example, if index2.php doesn't exist, it will look for index.php.