You're looping through list of files in folder to see if it matches *any* index file in list.

Web servers treat the list of index files as a prioritized list by file extension. In other words, it looks for index.html first, then index.htm, next, etc.

So, I think the loop needs to be inverted to loop through the index file list in prioritized order to see if it matches any file in folder.