@@ -1805,6 +1805,55 @@ with a locale. This can be done by defining a different prefix for each locale
1805
1805
;
1806
1806
};
1807
1807
1808
+ Another common requirement is to host the website on a different domain
1809
+ according to the locale. This can be done by defining a different host for each
1810
+ locale.
1811
+
1812
+ .. versionadded :: 5.1
1813
+
1814
+ The ability to define an array of hosts was introduced in Symfony 5.1.
1815
+
1816
+ .. configuration-block ::
1817
+
1818
+ .. code-block :: yaml
1819
+
1820
+ # config/routes/annotations.yaml
1821
+ controllers :
1822
+ resource : ' ../../src/Controller/'
1823
+ type : annotation
1824
+ host :
1825
+ en : ' https://www.symfony.com'
1826
+ nl : ' https://www.symfony.nl'
1827
+
1828
+ .. code-block :: xml
1829
+
1830
+ <!-- config/routes/annotations.xml -->
1831
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
1832
+ <routes xmlns =" http://symfony.com/schema/routing"
1833
+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
1834
+ xsi : schemaLocation =" http://symfony.com/schema/routing
1835
+ https://symfony.com/schema/routing/routing-1.0.xsd" >
1836
+
1837
+ <import resource =" ../../src/Controller/" type =" annotation" >
1838
+ <host locale =" en" >https://www.symfony.com</host >
1839
+ <host locale =" nl" >https://www.symfony.nl</host >
1840
+ </import >
1841
+ </routes >
1842
+
1843
+ .. code-block :: php
1844
+
1845
+ // config/routes/annotations.php
1846
+ use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;
1847
+
1848
+ return function (RoutingConfigurator $routes) {
1849
+ $routes->import('../../src/Controller/', 'annotation')
1850
+ ->host([
1851
+ 'en' => 'https://www.symfony.com',
1852
+ 'nl' => 'https://www.symfony.nl'
1853
+ ])
1854
+ ;
1855
+ };
1856
+
1808
1857
.. _stateless-routing :
1809
1858
1810
1859
Stateless Routes
0 commit comments