Closed
Description
Symfony version(s) affected
6.4.10
Description
The host locale feature in Symfony is intended to set the locale based on the request's host. However, this feature does not work for static routes defined in routing configuration files. While the host locale is correctly applied when using annotation routes, static routes do not respect this configuration, resulting in the inability to serve localized static content like robots.txt based on the domain or subdomain.
How to reproduce
Expected config (it not works)
robots_txt:
path: /robots.txt
host:
en: example.uk
de: example.de
defaults:
_controller: Symfony\Bundle\FrameworkBundle\Controller\TemplateController::templateAction
_format: txt
template: static/robots.txt.twig
Workaround (it works)
robots_txt.en:
path: /robots.txt
host: example.uk
defaults:
_locale: en
_controller: Symfony\Bundle\FrameworkBundle\Controller\TemplateController::templateAction
_format: txt
_canonical_route: robots_txt
template: static/robots.txt.twig
robots_txt.de:
path: /robots.txt
host: example.de
defaults:
_locale: de
_controller: Symfony\Bundle\FrameworkBundle\Controller\TemplateController::templateAction
_format: txt
_canonical_route: robots_txt
template: static/robots.txt.twig
Possible Solution
No response
Additional Context
No response