@@ -2206,6 +2206,53 @@ with a locale. This can be done by defining a different prefix for each locale
22062206 ;
22072207 };
22082208
2209+ Another common requirement is to host the website on a different domain
2210+ according to the locale. This can be done by defining a different host for each
2211+ locale.
2212+
2213+ .. versionadded :: 5.1
2214+
2215+ The ability to define an array of hosts was introduced in Symfony 5.1.
2216+
2217+ .. configuration-block ::
2218+
2219+ .. code-block :: yaml
2220+
2221+ # config/routes/annotations.yaml
2222+ controllers :
2223+ resource : ' ../../src/Controller/'
2224+ type : annotation
2225+ host :
2226+ en : ' https://www.symfony.com'
2227+ nl : ' https://www.symfony.nl'
2228+
2229+ .. code-block :: xml
2230+
2231+ <!-- config/routes/annotations.xml -->
2232+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2233+ <routes xmlns =" http://symfony.com/schema/routing"
2234+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
2235+ xsi : schemaLocation =" http://symfony.com/schema/routing
2236+ https://symfony.com/schema/routing/routing-1.0.xsd" >
2237+ <import resource =" ../../src/Controller/" type =" annotation" >
2238+ <host locale =" en" >https://www.symfony.com</host >
2239+ <host locale =" nl" >https://www.symfony.nl</host >
2240+ </import >
2241+ </routes >
2242+
2243+ .. code-block :: php
2244+
2245+ // config/routes/annotations.php
2246+ use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;
2247+ return function (RoutingConfigurator $routes) {
2248+ $routes->import('../../src/Controller/', 'annotation')
2249+ ->host([
2250+ 'en' => 'https://www.symfony.com',
2251+ 'nl' => 'https://www.symfony.nl'
2252+ ])
2253+ ;
2254+ };
2255+
22092256 .. _stateless-routing :
22102257
22112258Stateless Routes
0 commit comments