Skip to content

Redirect URLs with a Trailing Slash option #26207

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
soullivaneuh opened this issue Feb 17, 2018 · 5 comments
Closed

Redirect URLs with a Trailing Slash option #26207

soullivaneuh opened this issue Feb 17, 2018 · 5 comments

Comments

@soullivaneuh
Copy link
Contributor

soullivaneuh commented Feb 17, 2018

Q A
Bug report? no
Feature request? yes
BC Break report? no
RFC? no
Symfony version 4.0.4

On a classic Symfony setup, if we have a route with /en/blog url, we will get a 404 error if we try /en/blog/.

The documentation well explains how to handle that: https://symfony.com/doc/current/routing/redirect_trailing_slash.html

But I think it's a very common issue.

Why not proposing this as an option (IMHO, it should be activated by default) instead of telling the user to always write the same code? Reuse code is better than rewriting it. 👍

Of course, we may create a bundle instead. But I think this feature has his place on the internal Symfony codebase.

@soullivaneuh
Copy link
Contributor Author

soullivaneuh commented Feb 17, 2018

This doc PR should be considered too: symfony/symfony-docs#9286

@Tobion
Copy link
Contributor

Tobion commented Feb 18, 2018

See #26059 (comment)

@Simperfit
Copy link
Contributor

@Tobion so can we agree on doing this in symfony ?
@soullivaneuh if its validated, do you want to do it ?

@Tobion
Copy link
Contributor

Tobion commented Feb 23, 2018

yes I'm in favor of doing it

@nicolas-grekas
Copy link
Member

See #26283

Tobion added a commit that referenced this issue Feb 24, 2018
…n possible (nicolas-grekas)

This PR was merged into the 4.1-dev branch.

Discussion
----------

[Routing] Redirect from trailing slash to no-slash when possible

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #26207
| License       | MIT
| Doc PR        | -

Implemented as suggest by @Tobion in #26059 (comment)

When a route for `/foo` exists but the request is for `/foo/`, we now redirect.
(this complements the flipped side redirection, which already exists.)

Commits
-------

69a4e94 [Routing] Redirect from trailing slash to no-slash when possible
@Tobion Tobion closed this as completed Feb 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants