Remove apache's DirectoryIndex

Teneff asked:

Is it possible to turn apache’s DirectoryIndex off for specific directory using .htaccess file? I’ve tried DirectoryIndex Off but if file Off exists it uses it as index file. I want to make sure that the directory will be listed no matter what files are inside.

My answer:


You have a couple of options:

  1. Set DirectoryIndex to a filename that will never possibly exist.

    DirectoryIndex lni345hoqvgheruhgreoiuhgeroi30948yt0348
    
  2. Don’t load the mod_dir module. This, however, will disable the index.html style functionality for the entire server, and is probably not what you want.

Beginning with Apache 2.4 you can set DirectoryIndex disabled to disable its functionality.


View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.