Description
Hi,
Since SF 3.4 4.1, a new behavior regarding trailing slashes has been implemented. An other version of this behavior has been around forever. This behavior, largely documented, can be a little bit confusing and lead to some strange redirect in large applications.
As there is no real standard about this kind of redirect, I think this could be a better option to add a configuration key, to optionally disable all the automatic redirect to trailing slash or no stuff.
Following the comments on #32996 and #33362 this can be a valid use case to avoid a SEO risk.
Multiple options can be imagined to disable this behavior, with some pros and cons:
Global behavior:
General considerations:
Pros | Cons |
---|---|
Easy to use, easy to understand | If some 3rd party bundle relies on this feature, it can break things (suggested by @nicolas-grekas here - point 2 but not sure about a real use case here) |
Use UrlMatcher
instead of RedirectableUrlMatcher
:
Pros | Cons |
---|---|
No code, ready to use | Disable also https/http redirections and 405 |
Add a configuration key:
Pros | Cons |
---|---|
Easy to understand and to document | |
Very predictable |
Local behavior:
General considerations:
Pros | Cons |
---|---|
Greater control about this behavior | Easy to forget |
Unpredictable outcome if 2 concurrent routes have different configurations |
Use and document the syntax described here (regex with negative lookahead to forbid final slash if unwanted):
Pros | Cons |
---|---|
No code in sf | Hard to read and to debug |
Ready to use for dev |
Option on route declaration
Pros | Cons |
---|---|
Easy to understand and to use |
What do you think ? I'll update the list if I think to more pros / cons
Thanks,
--
Edited on 2019-08-30 with more precise description