Project

General

Profile

Actions

Bug #90579

closed

Redirects module only works on URLs with trailing slashes

Added by Florian Grell over 4 years ago. Updated 5 months ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Site Handling, Site Sets & Routing
Target version:
-
Start date:
2020-02-28
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
9
PHP Version:
7.3
Tags:
Complexity:
Is Regression:
Sprint Focus:
Needs Decision

Description

As an editor, I want to be create a redirect from "/source-path/" to "/source-path" (remove the trailing slash).
This leads to an infinite redirect loop.

Actions #1

Updated by Markus Klein over 4 years ago

Please post your Site configuration as well.

Actions #2

Updated by Florian Grell over 4 years ago

base: /
baseVariants: {  }
disableStaticFileCache: false
errorHandling:
  -
    errorCode: '404'
    errorHandler: Page
    errorContentSource: 't3://page?uid=50'
languages:
  -
    title: Deutsch
    enabled: true
    languageId: '0'
    base: /
    typo3Language: default
    locale: de_DE
    iso-639-1: de
    navigationTitle: ''
    hreflang: de-DE
    direction: ''
    flag: de
  -
    title: Englisch
    enabled: true
    languageId: '2'
    base: /en/
    typo3Language: default
    locale: en_US
    iso-639-1: en
    navigationTitle: ''
    hreflang: ''
    direction: ''
    fallbackType: strict
    fallbacks: '1'
    flag: en-us-gb
rootPageId: 1
routeEnhancers:
  NewsPlugin:
    type: Extbase
    extension: News
    plugin: Pi1
    routes:
      - routePath: '/'
        _controller: 'News::list'
      -
        routePath: '/{news_title}'
        _controller: 'News::detail'
        _arguments:
          news_title: news
      -
        routePath: '/{page}'
        _controller: 'News::list'
        _arguments:
          page: '@widget_0/currentPage'
    defaultController: 'News::list'
    defaults:
      page: '0'
    requirements:
      page: '\d+'
    aspects:
      page:
        type: StaticRangeMapper
        start: '1'
        end: '100'
      news_title:
        type: PersistedAliasMapper
        tableName: tx_news_domain_model_news
        routeFieldName: path_segment
  CoursePlugin:
    type: Extbase
    limitToPages:
      - 44
    extension: MyExtkey
    plugin: Myplugin
    routes:
      -
        routePath: '/{number}'
        _controller: 'Myplugin::detail'
        _arguments:
          number: number
    aspects:
      number:
        type: MypluginValueMapper
  PageTypeSuffix:
    type: PageType
    map:
      sitemap.xml: 1533906435
routes: {  }

Actions #3

Updated by Florian Grell over 4 years ago

I believe the problematic code is in the RedirectService, Lines 67-69:

if (!empty($allRedirects[$domainName]['flat'][rtrim($path, '/') . '/'])) {
    $possibleRedirects = $allRedirects[$domainName]['flat'][rtrim($path, '/') . '/'];
}

Actions #4

Updated by Benni Mack over 4 years ago

  • Status changed from New to Accepted
Actions #5

Updated by Georg Ringer 5 months ago

  • Sprint Focus set to Needs Decision

IMO this is not a bug. you could use https://packagist.org/packages/studiomitte/redirect2trailingslash to redirect to the version with slash.

is that ok for you?

Actions #6

Updated by Georg Ringer 5 months ago

  • Status changed from Accepted to Needs Feedback
Actions #7

Updated by Florian Grell 5 months ago

Georg Ringer wrote in #note-5:

IMO this is not a bug. you could use https://packagist.org/packages/studiomitte/redirect2trailingslash to redirect to the version with slash.

is that ok for you?

That would be the opposite of what I was trying to accomplish.
If I remember correctly my use-case was: I have a page with the URL "/somepage". Some external page has a link to this page, but they link to it with a trailing slash ("/somepage/") and I want to create a redirect to the url without the slash.

Actions #8

Updated by Benni Mack 5 months ago

  • Status changed from Needs Feedback to Closed

Hey Florian,

please check out https://b13.com/blog/to-slash-or-not-to-slash-the-significance-of-trailing-slashes-in-urls

This blog article also shows two extensions "de-slash" and "slash-force", I suggest you make use of one of them, as it solves all use-cases our clients had.

Actions

Also available in: Atom PDF