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
Copy file name to clipboardExpand all lines: system/HTTP/SiteURIFactory.php
+4-38Lines changed: 4 additions & 38 deletions
Original file line number
Diff line number
Diff line change
@@ -111,43 +111,9 @@ public function detectRoutePath(string $protocol = ''): string
111
111
*/
112
112
privatefunctionparseRequestURI(): string
113
113
{
114
-
$serverScriptName = $this->superglobals->server('SCRIPT_NAME'); // This is the SCRIPT_NAME, it's a variable that contains the name of the script being executed, it's used from the codeigniter framework to perform the routing process.
115
-
// We need to check if the project is in a subdirectory
116
-
$projectIsInSubDir = false; // Variable used to check if the project is in a subdirectory
117
-
$baseURLConfig = config(\Config\App::class)->baseURL; // Base URL configuration from the Config\App class or .env file
118
-
$baseUrlParsed = parse_url($baseURLConfig); // PHP function to parse the URL
119
-
$baseUrlPath = ""; // If the url does not have a / at the end like https://example.com the path will not be set by parse_url
120
-
if(isset($baseUrlParsed['path'])) { // Check if the path is set in the parsed URL (read the line above)
121
-
$baseUrlPath = $baseUrlParsed['path'] ?? "";
122
-
}
123
-
124
-
// We need to check that the project is in a subdirectory, if it is in a subdirectory we need to remove the public directory from the script name
if(count($baseUrlPathArr) > 0){ // Check that the path has at least one fragment
130
-
$projectIsInSubDir = true; // The project is running in a subdirectory
131
-
}
132
-
133
-
// We need to remove public from the script name, this way we can correctly perform the routing
134
-
if($projectIsInSubDir){
135
-
$subDirPath = "/" . implode("/", $baseUrlPathArr); // This is the path of the subdirectory, we are using arrays because it can be multiple levels deep
136
-
$subDirPathPosition = strpos($serverScriptName, $subDirPath."/public"); // This is the position of the public directory in the script name. The strpos function returns only the first instance
137
-
if ($subDirPathPosition !== false) { // We are checking if the public directory is found in the script name.
138
-
$serverScriptName = substr_replace(
139
-
$serverScriptName, // The input string.
140
-
$subDirPath, // The replacement string.
141
-
$subDirPathPosition, // The offset from where we are replacing.
142
-
strlen($subDirPath."/public") // The length of the portion of string which is to be replaced.
0 commit comments