From 3e545895b256aaca3495bae798ab2f4084b1d60d Mon Sep 17 00:00:00 2001
From: Lorenz Stechauner <lorenz.stechauner@gmail.com>
Date: Wed, 20 Nov 2019 14:01:11 +0100
Subject: [PATCH] Probably fixed URI path info

---
 src/URI.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/URI.cpp b/src/URI.cpp
index ec3b6b0..8fd41e7 100644
--- a/src/URI.cpp
+++ b/src/URI.cpp
@@ -63,7 +63,9 @@ URI::URI(string webroot, string reqpath) {
 	info = "";
 	relpath = reqpath;
 
-	while (!fileExists(webroot + relpath) && !fileExists(webroot + relpath + ".php") && !fileExists(webroot + relpath + ".html")) {
+	while ((!fileExists(webroot + relpath) || (isDirectory(webroot + relpath) && !fileExists(webroot + relpath + "/index.php")))
+	        && (!fileExists(webroot + relpath + ".php") || (isDirectory(webroot + relpath + ".php") && !fileExists(webroot + relpath + ".php/index.php")))
+	        && (!fileExists(webroot + relpath + ".html") || (isDirectory(webroot + relpath + ".html") && !fileExists(webroot + relpath + ".html/index.php")))) {
 		long slash = relpath.find_last_of('/');
 		if (slash == string::npos) {
 			break;