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