[BUGFIX] Ensure www.mydomain.com/index.php works 03/60503/2
authorBenni Mack <benni@typo3.org>
Wed, 17 Apr 2019 21:17:00 +0000 (23:17 +0200)
committerSusanne Moog <look@susi.dev>
Thu, 18 Apr 2019 14:18:50 +0000 (16:18 +0200)
Calling just "index.php" without "id" and "type" parameter
should work as expected, as before.

Resolves: #88028
Releases: master, 9.5
Change-Id: I36df591b8b334b9b5908563ca554cab98acba32a
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/60503
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Alexander Opitz <opitz.alexander@googlemail.com>
Tested-by: Josef Glatz <josefglatz@gmail.com>
Tested-by: Susanne Moog <look@susi.dev>
Reviewed-by: Alexander Opitz <opitz.alexander@googlemail.com>
Reviewed-by: Josef Glatz <josefglatz@gmail.com>
Reviewed-by: Susanne Moog <look@susi.dev>
typo3/sysext/core/Classes/Routing/PageRouter.php

index b0a2112..5b63df2 100644 (file)
@@ -29,6 +29,7 @@ use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
 use TYPO3\CMS\Core\Database\Query\Restriction\FrontendWorkspaceRestriction;
 use TYPO3\CMS\Core\Exception\SiteNotFoundException;
+use TYPO3\CMS\Core\Http\NormalizedParams;
 use TYPO3\CMS\Core\Http\Uri;
 use TYPO3\CMS\Core\Routing\Aspect\AspectFactory;
 use TYPO3\CMS\Core\Routing\Aspect\MappableProcessor;
@@ -117,6 +118,17 @@ class PageRouter implements RouterInterface
             throw new RouteNotFoundException('No previous result given. Cannot find a page for an empty route part', 1555303496);
         }
         $urlPath = $previousResult->getTail();
+        // Remove the script name (e.g. index.php), if given
+        if (!empty($urlPath)) {
+            $normalizedParams = $request->getAttribute('normalizedParams');
+            if ($normalizedParams instanceof NormalizedParams) {
+                $scriptName = ltrim($normalizedParams->getScriptName(), '/');
+                if (strpos($urlPath, $scriptName) !== false) {
+                    $urlPath = str_replace($scriptName, '', $urlPath);
+                }
+            }
+        }
+
         $prefixedUrlPath = '/' . trim($urlPath, '/');
         $slugCandidates = $this->getCandidateSlugsFromRoutePath($urlPath ?: '/');
         $pageCandidates = [];