Skip to content

Commit 89ce426

Browse files
committed
fix: fixed the codeigniter routing for installations in subdirectories with the page index 2.
- in the SiteURIFactory I made sure the requestUri starts with a slash - in the SiteURIFactory I checked that the requestUri is not null The code passes the SiteURIFactoryTest
1 parent 4343fe4 commit 89ce426

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

system/HTTP/SiteURIFactory.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,10 @@ private function parseRequestURI(): string
132132
}
133133

134134
$serverRequestUri = $this->superglobals->server('REQUEST_URI'); // We get the request URI from the server superglobals
135-
if($baseUri) $serverRequestUri = ltrim($serverRequestUri, $baseUri); // We remove the base Uri from the request URI if it exists, baseUri is the path to the subdirectory
136-
if($indexPage) $serverRequestUri = ltrim($serverRequestUri, "/" . $indexPage); // We remove the index page from the request URI if it exists
135+
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+
$serverRequestUri = "/". ltrim($serverRequestUri, '/'); // makes sure that the uri starts with a slash
137139

138140
if (
139141
$serverRequestUri === null

0 commit comments

Comments
 (0)