Bug 62882

Summary: DirectoryIndex arguments match prefix of filenames, not exact filenames
Product: Apache httpd-2 Reporter: Björn Wiberg <bjorn.wiberg>
Component: mod_dirAssignee: Apache HTTPD Bugs Mailing List <bugs>
Status: RESOLVED INVALID    
Severity: minor CC: bjorn.wiberg
Priority: P2    
Version: 2.4.25   
Target Milestone: ---   
Hardware: PC   
OS: Linux   

Description Björn Wiberg 2018-11-04 06:57:04 UTC
The arguments given to DirectoryIndex, when one specifies filenames, appear to specify *prefixes* of what mod_dir should be looking for rather than exact filenames.

If you, for example, have:

DirectoryIndex index.php index.pl index.cgi index.phtml index.shtml index.xhtml index.html.var index.html index.htm default.php

...and then add a GIF file called "index.html.gif" to an autoindexed directory, Apache appears to happily serve that GIF file as the directory index, although DirectoryIndex only specifies "index.html".

Other configurations options in effect (for reference, in case they would influence):

IndexOptions FancyIndexing VersionSort HTMLTable NameWidth=* DescriptionWidth=* Charset=UTF-8
IndexOptions +FoldersFirst -HTMLTable +IconHeight +IconWidth +IgnoreCase +ScanHTMLTitles
IndexOptions +UseOldDateFormat


...and for mod_negotiation:

LanguagePriority en ca cs da de el eo es et fr he hr it ja ko ltz nl nn no pl pt pt-BR ru sv tr zh-CN zh-TW
ForceLanguagePriority Prefer Fallback

...and for core:

Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
Comment 1 Christophe JAILLET 2018-11-04 08:42:07 UTC
This not a bug.

Have a look at:
   https://httpd.apache.org/docs/2.4/en/content-negotiation.html#multiviews
   https://httpd.apache.org/docs/2.4/en/mod/mod_negotiation.html#multiviews

It explains the way 'MultiViews' works. (especially "MultiViews may also apply to searches for the file named by the DirectoryIndex directive, if the server is trying to index a directory.")