retrieve only relevant uri path for git over http
diff --git a/src/backend.c b/src/backend.c
index baf02c2..14908dd 100644
--- a/src/backend.c
+++ b/src/backend.c
@@ -187,6 +187,7 @@
 	int c;
 	int slashes = 0;
 	const char *start, *end;
+	int depth = 1;
 
 	if (px->lbprm.tot_weight == 0)
 		return NULL;
@@ -198,17 +199,18 @@
 	if (px->uri_len_limit)
 		uri_len = MIN(uri_len, px->uri_len_limit);
 
-	start = end = uri;
+	start = uri;
+	end = uri + uri_len - 1;
 	while (uri_len--) {
 		c = *end;
 		if (c == '/') {
 			slashes++;
-			if (slashes == px->uri_dirs_depth1) /* depth+1 */
+			if (slashes == depth)
 				break;
 		}
-		else if (c == '?' && !px->uri_whole)
-			break;
-		end++;
+		else if (c == '?')
+			depth = 2;
+		end--;
 	}
 
 	hash = gen_hash(px, start, (end - start));