Bug #94499

Redirect after slug update doesn't respect suffix

Added by Martin Tepper 5 months ago. Updated 2 months ago.

Status:
New
Priority:
Should have
Assignee:
-
Category:
Link Handling, Site Handling & Routing
Target version:
-
Start date:
2021-07-07
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
10
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

Hello,

in my system i have the routeEnhancers configured with

routeEnhancers:
  PageTypeSuffix:
    type: PageType
    default: '.html'
    map:
      '.html': 0

my urls are looking like www.domain.com/page.html

when i change the slug from "page" to "page-new" a new redirect is created with
Source Path: /page
Destination: /page-new

i expected that a request to the old address www.domain.com/page.html will redirect to www.domain.com/page-new.html.

but the redirect works only for www.domain.com/page and redirects to www.domain.com/page-new.
so the redirect doesn't work in my case and has no advantages for already indexed urls.

when i change the redirect entry manually to
Source Path: /page.html
Destination: /page-new.html

it works like expected.

Is there a solution or a setting that I am overlooking?


Files

#1

Updated by Michael Sollmann 5 months ago

Can confirm this!

#2

Updated by Martin Tepper 3 months ago

Wrote a very rudimentary patch for this.
But i think there is a better solution to solve it maybe in the urlBuilder. I will check when i have more time.

#3

Updated by Jörg Velletti 2 months ago

this patch does nearly what it should do.

put is also needed in checkSubPages

    protected function checkSubPages(array $currentPageRecord, string $oldSlugOfParentPage, string $newSlugOfParentPage): void
    {
        $languageUid = (int)$currentPageRecord['sys_language_uid'];
        // resolveSubPages needs the page id of the default language
        $pageId = $languageUid === 0 ? (int)$currentPageRecord['uid'] : (int)$currentPageRecord['l10n_parent'];
        $subPageRecords = $this->resolveSubPages($pageId, $languageUid);
        $suffix = $this->getUrlSuffixForPageType();
        foreach ($subPageRecords as $subPageRecord) {
            $newSlug = $this->updateSlug($subPageRecord, $oldSlugOfParentPage, $newSlugOfParentPage);
            if ($newSlug !== null && $this->autoCreateRedirects) {

                $this->createRedirect($subPageRecord['slug'] . $suffix , $newSlug . $suffix , $languageUid);
            }
        }
    }

means: add also her a :

  $suffix = $this->getUrlSuffixForPageType();

and inside the Foreach loop add two times .$suffix


                $this->createRedirect($currentSlug . $suffix, $newSlug . $suffix, languageUid );

Also available in: Atom PDF