@@ -370,7 +370,6 @@ function bootstrap()
370
370
$ uri_path = $ this ->URI_no_query ();
371
371
$ uri_filepath = $ _SERVER ['DOCUMENT_ROOT ' ] . '/ ' . urldecode (substr ($ uri_path , 1 ));
372
372
373
-
374
373
$ load_index = $ _SERVER ['DOCUMENT_ROOT ' ] . "/ " . $ this ->indexPath ;
375
374
$ load_index = $ this ->format_unix (trim ($ load_index ));
376
375
@@ -679,6 +678,37 @@ function fix_path_info()
679
678
680
679
}
681
680
681
+
682
+ /**
683
+ * Autodetect index
684
+ */
685
+ function autoDetectIndex ()
686
+ {
687
+
688
+ $ indexRoot = $ _SERVER ["DOCUMENT_ROOT " ] . '/ ' . $ this ->indexPath ;
689
+
690
+ if (!file_exists ($ indexRoot )) {
691
+
692
+ $ viableFilesForIndex = array ('index.php ' , 'index.phtml ' , 'index.html ' , 'index.htm ' , 'index.html5 ' , 'index.php5 ' );
693
+
694
+ $ scanRoot = scandir ($ _SERVER ["DOCUMENT_ROOT " ]);
695
+ $ scanRoot = array_filter ($ scanRoot , function ($ k ) use ($ viableFilesForIndex ) {
696
+ return in_array (strtolower ($ k ), $ viableFilesForIndex );
697
+ });
698
+ $ scanRoot = array_values ($ scanRoot );
699
+
700
+ if (count ($ scanRoot )) {
701
+
702
+ $ this ->indexPath = $ scanRoot [0 ];
703
+
704
+ }
705
+
706
+ }
707
+
708
+
709
+ }
710
+
711
+
682
712
/**
683
713
* Listen for requests
684
714
* @return bool|mixed
@@ -690,9 +720,10 @@ function listen()
690
720
$ this ->init ();
691
721
$ this ->log_output ();
692
722
693
-
694
723
$ falsy_ext = $ this ->getExt ($ this ->URI_no_query ());
695
724
725
+ $ this ->autoDetectIndex ();
726
+
696
727
if (in_array ($ falsy_ext , array ("" , "php " ))) {
697
728
698
729
/**
0 commit comments