From f82ea727b39bce4b96ede5354cc2d032b929150c Mon Sep 17 00:00:00 2001 From: Olivier Dolbeau Date: Mon, 20 Apr 2020 10:25:06 +0200 Subject: [PATCH] Explain host per locale --- routing.rst | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/routing.rst b/routing.rst index 76184d7c8ef..ae55ec27194 100644 --- a/routing.rst +++ b/routing.rst @@ -1805,6 +1805,55 @@ with a locale. This can be done by defining a different prefix for each locale ; }; +Another common requirement is to host the website on a different domain +according to the locale. This can be done by defining a different host for each +locale. + +.. versionadded:: 5.1 + + The ability to define an array of hosts was introduced in Symfony 5.1. + +.. configuration-block:: + + .. code-block:: yaml + + # config/routes/annotations.yaml + controllers: + resource: '../../src/Controller/' + type: annotation + host: + en: 'https://www.symfony.com' + nl: 'https://www.symfony.nl' + + .. code-block:: xml + + + + + + + https://www.symfony.com + https://www.symfony.nl + + + + .. code-block:: php + + // config/routes/annotations.php + use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator; + + return function (RoutingConfigurator $routes) { + $routes->import('../../src/Controller/', 'annotation') + ->host([ + 'en' => 'https://www.symfony.com', + 'nl' => 'https://www.symfony.nl' + ]) + ; + }; + .. _stateless-routing: Stateless Routes