Since version 4.1, Symfony now handles multilingual routing without the need of an external plugin (https://symfony.com/blog/new-in-symfony-4-1-internationalized-routing). I've translated my routes with success and all works fine except that when accessing the root url ("/"), Symfony renders a 404 error instead of redirecting to a language folder such as "/en/".
I've done some research but most of what i've found is very outdated (mostly Symfony 2). Also ran into this Symfony 3 Redirect All Routes To Current Locale Version but it seems like an incredibly tedious solution to such a simple problem.
Ideally, i'd also like to redirect the url "/admin" to "/en/admin", but if i can't achieve it i can live with that.
Here's my routes/annotations.yaml file:
controllers:
resource: ../../src/Controller/
type: annotation
prefix:
fr: '/fr'
en: '/en'
de: '/de'
My translations .yaml file:
framework:
#default_locale: '%locale%'
default_locale: 'en'
translator:
paths:
- '%kernel.project_dir%/translations'
fallbacks:
- 'en'
Home route configuration:
@Route("/", name="home")
@Route
annotations for your homepage controller and action method? – Will B.