I'm trying to set up routing system with subdomain representing current locale. Routing is set via @Routing
annotation and looks like this:
/**
* @Route(
* "/",
* name="homepage",
* host="{locale}.{domain}",
* defaults={"locale" = "en", "domain" = "%domain%"},
* requirements={"locale" = "en|de|fr", "domain" = "%domain%"}
* )
*/
Works well for URL's like en.somedomain.com
or de.somedomain.com
, but fails to find correct route for somedomain.com
, without locale.
I understand that because of the host
parameter, that is set to represent exact locale.domain pattern, but I can't find way to tell Symfony routing system that there could be additional, default host
.
Searched all around for this, but found nothing particular. Would appreciate any help!
UPDATE
There is actually a way to do it, by adding another @Route
in annotation, without host
parameter:
/**
* @Route(
* "/",
* name="homepage_default",
* defaults={"locale" = "en"}
* )
*/
but thats looks a bit dirty, and I'm not using %domain%
parameter there, which is important for me - say, if I would need another subdomain for mobile version.