Bug #94499

Redirect after slug update doesn't respect suffix

Added by Martin Tepper 7 months ago. Updated about 1 month 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


Related issues

Related to TYPO3 Core - Bug #93483: Redirects: .html page suffix not supportedNew2021-02-10

Actions
Related to TYPO3 Core - Bug #92101: Redirects: File Extension breaks redirectNeeds Feedback2020-08-26

Actions
#1

Updated by Michael Sollmann 7 months ago

Can confirm this!

#2

Updated by Martin Tepper 5 months ago

  • File 94499-redirect_without_suffix.diff added

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 4 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 );
#4

Updated by DANIEL Rémy about 2 months ago

  • Related to Bug #93483: Redirects: .html page suffix not supported added
#5

Updated by DANIEL Rémy about 2 months ago

  • Related to Bug #92101: Redirects: File Extension breaks redirect added
#6

Updated by DANIEL Rémy about 2 months ago

Hi

I think the "urlSuffixForPageType" should not be stored in the record's slug.

The suffix should be either evaluated at the matching time (RedirectService::matchRedirect()) or added to the cache (RedirectCacheService::getRedirects())

#7

Updated by Martin Tepper about 1 month ago

I'm with you. That would be a better way

#8

Updated by Martin Tepper about 1 month ago

I'd took a deeper look into an implmentation via RedirectService::matchRedirect() and found some obstacles.

  • no siteConfiguration evaluation possible at this point. required to get available suffixes by site
  • an implementation at this point would have a negative impact on performance

i'm still with you to evaluate it at the matching time. i don't see a possibility for now.

Do you have an idea?

#9

Updated by Martin Tepper about 1 month ago

  • File deleted (94499-redirect_without_suffix.diff)
#10

Updated by Martin Tepper about 1 month ago

added a new version for TYPO3 >= 10.4.22

Also available in: Atom PDF