Skip to content

Commit 9063df5

Browse files
committed
fix: fixed the codeigniter routing for installations in subdirectories with the page index 4.
I replaced the instances of ltrim with a combination of str_starts_with and substr
1 parent 74ef94a commit 9063df5

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

system/HTTP/SiteURIFactory.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,11 @@ private function parseRequestURI(): string
133133

134134
$serverRequestUri = $this->superglobals->server('REQUEST_URI'); // We get the request URI from the server superglobals
135135

136-
if($baseUri && !is_null($serverRequestUri)) $serverRequestUri = ltrim($serverRequestUri, $baseUri); // We remove the base Uri from the request URI if it exists, baseUri is the path to the subdirectory
137-
if($indexPage && !is_null($serverRequestUri)) $serverRequestUri = ltrim($serverRequestUri, "/" . $indexPage); // We remove the index page from the request URI if it exists
138-
if(!is_null($serverRequestUri)) $serverRequestUri = "/". ltrim($serverRequestUri, '/'); // makes sure that the uri starts with a slash
136+
if(!is_null($serverRequestUri)){
137+
if($baseUri && str_starts_with($serverRequestUri, $baseUri)) $serverRequestUri = substr($serverRequestUri, strlen($baseUri)); // We remove the base Uri from the request URI if it exists, baseUri is the path to the subdirectory
138+
if($indexPage && str_starts_with($serverRequestUri, "/" . $indexPage)) $serverRequestUri = substr($serverRequestUri, strlen("/" . $indexPage)); // We remove the index page from the request URI if it exists
139+
$serverRequestUri = "/". ltrim($serverRequestUri, '/'); // makes sure that the uri starts with a slash
140+
}
139141

140142
if (
141143
$serverRequestUri === null

0 commit comments

Comments
 (0)