Skip to content

[Routing] Route with trailing slash redirects to route without slash #29438

Closed
@emodric

Description

@emodric

Symfony version(s) affected: 4.2.0 and 4.1.8

Description

I have two routes, one without slash, one with the slash, and with 4.2.0 and 4.1.8, there is a redirect from the route with the slash to the route without the slash, causing infinite redirect loop between the two (obviously because the no-slash route redirects back to slash route). #29380 also does not fix the issue.

This works fine on Symfony 4.1.7 and latest 3.4, i.e. no redirect happens from slash route to no-slash route.

How to reproduce

The following routes cause the problem:

test_route_no_slash:
    path: /foo
    methods: [GET]
    defaults:
        _controller: "Symfony\\Bundle\\FrameworkBundle\\Controller\\RedirectController::redirectAction"
        route: test_route
        permanent: true

test_route:
    path: /foo/
    methods: [GET]
    defaults:
        _controller: "App\\Controller\\FooController"

Reproducer is available at https://github.com/emodric/sf_route_redirect_bug

Start the server and open /foo to get the infinite redirects.

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