Skip to content

[Routing] Trailing slash redirection prevents routes to be matched #32996

Closed
@Jean-Gian

Description

@Jean-Gian

Symfony version(s) affected: 4.3.3

Description
When using yaml to configure routes, if I have 2 routes that only differs on the trailing slash (/foo and /foo/) only the first one in the yaml file works, the second one always redirect to the first one.
This happens with hard coded routes (/foo) or with wildcards (/{param})
The documentation says this should not happen: https://symfony.com/doc/current/routing.html#routing-trailing-slash-redirection

How to reproduce
The routing yaml file is:

foo_slash: #working
  path:       /foo/
  controller: App\Controller\Slash:foo
foo_no_slash: #not working, redirecting to foo_slash
  path:       /foo
  controller: App\Controller\NoSlash:foo
bar_no_slash: #working
  path:       /bar
  controller: App\Controller\NoSlash:bar
bar_slash: #not working, redirecting to bar_no_slash
  path:       /bar/
  controller: App\Controller\Slash:bar

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions