diff --git a/phpBB/docs/CHANGELOG.html b/phpBB/docs/CHANGELOG.html
index 49c8d1364b..7b8d8f63f2 100644
--- a/phpBB/docs/CHANGELOG.html
+++ b/phpBB/docs/CHANGELOG.html
@@ -102,6 +102,7 @@
[Fix] Parsing urls in signatures properly uses config settings. (Bug #57105)
[Fix] Allow multibyte keys in request_var(). (Bug #51555)
[Fix] Prevent wrong tar archive type detection. (Bug #12531)
+ [Fix] Correct redirection after login to forum not in web root (Bug #58755)
[Feature] Support for Microsoft's Native SQL Server Driver for PHP (Bug #57055 - Patch by Chris Pucci at Microsoft)
diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php
index 11f1896332..1a302d5991 100644
--- a/phpBB/includes/session.php
+++ b/phpBB/includes/session.php
@@ -83,7 +83,7 @@ class session
$query_string = trim(implode('&', $use_args));
// basenamed page name (for example: index.php)
- $page_name = basename($script_name);
+ $page_name = (substr($script_name, -1, 1) == '/') ? '' : basename($script_name);
$page_name = urlencode(htmlspecialchars($page_name));
// current directory within the phpBB root (for example: adm)