You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: fixed the codeigniter routing for installations in subdirectories with the page index.
I fixed the codeigniter routing for installations in subdirectories by removing the path to the subdirectory from the uri during the routing process in the SiteURIFactory.
I am still testing the change as it's in a very sensible area of the code.
I also still need to write tests for this change. I will do that soon.
Copy file name to clipboardExpand all lines: system/HTTP/SiteURIFactory.php
+26-2Lines changed: 26 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -111,8 +111,32 @@ public function detectRoutePath(string $protocol = ''): string
111
111
*/
112
112
privatefunctionparseRequestURI(): string
113
113
{
114
+
$appConfig = config(\Config\App::class);
115
+
$baseUrl = $appConfig->baseURL;
116
+
$indexPage = $appConfig->indexPage;
117
+
$baseUri = false;
118
+
$parsedUrl = parse_url($baseUrl);
119
+
120
+
if(isset($parsedUrl['path'])){ // The path could be empty if the url is just a domain
121
+
$baseUri = $parsedUrl['path'];
122
+
}
123
+
if($baseUri){
124
+
$baseUriArray = explode('/', $baseUri);
125
+
$baseUriArray = array_filter($baseUriArray); // We remove the empty strings from the array
126
+
$baseUri = implode('/', $baseUriArray); // We join the array back into a string with slashes
127
+
if(strlen($baseUri) > 0){
128
+
$baseUri = "/" . $baseUri; // We add a slash at the beginning of the base Uri as implode will not do that
129
+
}else{
130
+
$baseUri = false;
131
+
}
132
+
}
133
+
134
+
$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
0 commit comments