diff --git a/typo3/sysext/frontend/Classes/Typolink/PageLinkBuilder.php b/typo3/sysext/frontend/Classes/Typolink/PageLinkBuilder.php
index 363c31eefb436157abf99974fa8b78da9e919596..7c973a7a1edabb666c8a4b84f41a8194a4d3c74f 100644
--- a/typo3/sysext/frontend/Classes/Typolink/PageLinkBuilder.php
+++ b/typo3/sysext/frontend/Classes/Typolink/PageLinkBuilder.php
@@ -559,7 +559,7 @@ class PageLinkBuilder extends AbstractTypolinkBuilder
         // $totalUri contains /index.php for legacy URLs, as previously "it was index.php"
         // In case an URI has is prefixed with "/" which is not the absRefPrefix, remove it.
         // this might change in the future
-        if (strpos($totalUrl, '/index.php') === 0 && strpos($totalUrl, $absRefPrefix) !== 0) {
+        if (strpos($totalUrl, '/index.php') === 0 && $absRefPrefix !== '/') {
             $totalUrl = substr($totalUrl, 1);
         }