Skip to content

Commit 9f5f8b7

Browse files
author
Designcise
committed
Added workaround for using subfolders as the root folder
1 parent 886d015 commit 9f5f8b7

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "designcise/bitframe",
3-
"version": "1.0.2",
3+
"version": "1.0.3",
44
"description": "PHP PSR-15 / PSR-7 middleware dispatcher microframework",
55
"type": "library",
66
"keywords": ["Designcise", "BitFrame", "Microframework", "Framework", "Middleware Dispatcher", "PSR-7", "PSR-15"],

src/Factory/HttpMessageFactory.php

100644100755
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,10 @@ public static function createServerRequestFromArray(
133133
self::$serverRequestFactory = new \BitFrame\Factory\ServerRequestFactory();
134134
}
135135

136-
// workaround for localhost
137-
if (in_array(self::get('REMOTE_ADDR', $server, []), ['127.0.0.1', '::1']) && ($index = strpos($server['PHP_SELF'], '/index.php')) !== false && $index > 0) {
136+
// workaround for when using subfolders as the root folder; this would make
137+
// folder containing the main 'index.php' file the root, which is the expected
138+
// behavior
139+
if (($index = strpos($server['PHP_SELF'], '/index.php')) !== false && $index > 0) {
138140
$script_url = strtolower(substr($server['PHP_SELF'], 0, $index));
139141
$server['REQUEST_URI'] = '/' . trim(str_replace(['/index.php', $script_url], '', $server['REQUEST_URI']), '/');
140142
}

0 commit comments

Comments
 (0)