Issue Bug New Orphaned

#102901Automatically created redirects can point to the same URL as the source

Philipp Wrann 01/23/24, 15:03 updated 01/30/26, 09:59

Description

If you update a slug, typo3 will create a redirect that removes all additional query params (“Keep GET Parameters” = off).

It may happen, that – through changing of slugs – a redirect is created, that effectively looks this way:

curl -I ‘https://my.site/path/to/page?type=200&cHash=someCacheHash’

HTTP/2 307 
content-type: text/html; charset=UTF-8
x-redirect-by: TYPO3 Redirect 101
location: https://my.site/path/to/page

So when generating those links in your fluid template you will never receive the content you want to load, you will always load page type 0.

This affects all required query parameters.

My suggestion:
If the source and the generated target url are the same:

1) dont send the redirect
2) if not protected, delete the obsolete redirect

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.

Fix this issue

Start the commit message of your patch with this. Add what the patch does, and the versions it goes to in "Releases:". How to create a patch

Commit message
[BUGFIX] Automatically created redirects can point to the same URL as the source Resolves: #102901 Releases: main

History 5

  1. Philipp Wrann commented and changed description <span data-processor="relativetime" data-value="2024-01-23T15:09:26+00:00" > 01/23/24, 15:09 </span>

    Changed the location url so its clear the urls are the same

  2. Stefan Bürk commented <span data-processor="relativetime" data-value="2024-01-23T17:01:38+00:00" > 01/23/24, 17:01 </span>

    First, you should not use “hardcoded” links in templates. Instead use proper
    viewhelper which updates the correct page link after the slug has changed -
    so not hitting the redirect anyway (directly).

    For v11 you could disable the redirect auto creation and create custom
    datahandler hook for it.

    TYPO3 v12 introduced a handfull PSR-14 events around the auto redirect
    creation where you can influence what kind/type of redirect is created
    or create additional redirects beside the plain one.

    The decision to make auto-redirect in a plain form is there since TYPO3
    v9 and therefore we should not consider this as a bug and changing the
    behaviour for all in a long standing LTS version.

    And as already mentioned – you can adjust this for your instance using
    events with TYPO3 v12 – and also doing quite more things.

    For example:

    https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/12.3/Feature-94499-ProvideAdditionalPageTypeSourceAuto-createRedirectSourceType.html
    https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/12.3/Feature-99834-NewPSR-14ModifyAutoCreateRedirectRecordBeforePersistingEvent.html
    https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/12.2/Feature-99746-NewPSR-14SlugRedirectChangeItemCreatedEvent.html

    and other.

  3. Philipp Wrann commented <span data-processor="relativetime" data-value="2024-01-23T17:35:05+00:00" > 01/23/24, 17:35 </span>

    > First, you should not use “hardcoded” links in templates. Instead use proper viewhelper which updates the correct page link after the slug has changed – so not hitting the redirect anyway (directly).

    Where did i write, that i did that?

    In our case we did just what you suggested – we utilized the f:uri.page ViewHelper. But because the generated URL is exactly the same as the redirect source path typo3 will send a redirect – even if its for no reason.

    > For v11 you could disable the redirect auto creation and create custom datahandler hook for it.

    That advice is no solution to the bug – yes this is a bug.

    > TYPO3 v12 introduced a handfull PSR-14 events around the auto redirect creation where you can influence what kind/type of redirect is created or create additional redirects beside the plain one.

    Neither would this be a solution because the behaviour should be correct using defaults only.

    We don’t deal with an edge case here, we don’t deal with using “hardcoded links”, we deal with typo3 behaving wrongly when using its very “core api features” exactly as they are documented.

    I think it should be possible to reproduce this:

    1) Create a page (lets assume it has uid 2) with the slug /test
    2) Add any kind of typolink generation including some additionalParams (either use fluid, typoscript, whatever, the same link generation will kick in in the end
    3) change the slug of the new page to /test2 (a redirect /test => t3://page?uid=2 will be added but GET paramters will be removed on redirect)
    4) change the slug back to /test (a redirect /test2 => t3://page?uid=2 will be added like before)

    At this point any correctly generated link, that points to /test will be redirected because redirect number 1 is still there. But all GET params will be removed for the location header.

    The behaviour is clearly wrong.

  4. Alexander Schnitzler commented <span data-processor="relativetime" data-value="2026-01-30T09:59:57+00:00" > 01/30/26, 09:59 </span>

    I encountered this bug as well. Let me shortly re-explain the setup.

    An editor creates a page with path /foo/bar/, then renames the path to /foo/bar. The system creates a redirect with respect_query_parameters disabled.

    Using the router (TYPO3 API) via PHP or Fluid, you get links without a trailing slash now (which is correct). The redirect middleware however always tries to match paths WITH a trailing slash and this also applies to links to paths WITHOUT a trailing slash but WITH query params.

    Example:

    /for/bar?baz=1

    As respect_query_parameters is disabled, the redirect matcher takes the original path /foo/bar, modifies it to /foo/bar/ and then has a match, although there’s no need to redirect at all.

    This is problematic in cases where you have a plugin on the target page that acts differently depending on the query params. The links are properly generated but as the user clicks the link wrong content is returned.

    The problem is that all this can happen with a site being live for long, working and suddenly that behaviour breaks a plugin.