Skip to content

[Routing] Unexpected redirect with trailing slash #29575

Closed
@iquito

Description

@iquito

Symfony version(s) affected: 4.1.8+

Description

Symfony now redirects routes with trailing slashes to routes without trailing slashes on its own, which seems unexpected and like a bad practice, as two URLs are treated equally which are not automatically equal by any official standards.

URLs in my application never have a trailing slash, and if a link points towards an URL with a trailing slash this should always be treated as a 404, which can then be captured and logged by my application to find out why there was an incorrect link. Symfony now decides on its own that an URL followed by a slash is equal to the same URL without the trailing slash and does an additional redirect, which seems like an arbitrary convention and is a BC break.

I also feel Symfony doing redirects bypassing the application is unexpected in its own way - I expect routes to be matched, but not Symfony to decide how to redirect URLs and changing my URLs. In my case this broke part of my application, because suddenly there was an additional unexpected redirect which was not issued by my application but by Symfony itself.

Possible Solution

As far as I can tell there is no way for me to bypass this functionality - no option to switch it off, nothing to do (I went through all Symfony documentation, and this now seems to be required behavior). Generally, I want to turn off ANY automatic redirection of Symfony, as this is the responsibility of my application.

So if this change really needs to happen, then there should be a possibility to turn it off. There might also be possibilities to make the router more succinct if the whole trailing slash or not part does not need to be in there, because matching something 1:1 must be a lot easier and less error-prone than also checking about trailing slashes or not.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions