From ebb266c6a92a43657516f743921171401e90b012 Mon Sep 17 00:00:00 2001 From: Thibault RICHARD Date: Sun, 28 Feb 2021 12:07:57 +0100 Subject: [PATCH] [Routing] Explain host per locale --- routing.rst | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/routing.rst b/routing.rst index bf971924311..7ac8e756036 100644 --- a/routing.rst +++ b/routing.rst @@ -2206,6 +2206,53 @@ 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