Skip to content

Commit f82ea72

Browse files
author
Olivier Dolbeau
committed
Explain host per locale
1 parent 2dd492c commit f82ea72

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

routing.rst

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1805,6 +1805,55 @@ with a locale. This can be done by defining a different prefix for each locale
18051805
;
18061806
};
18071807
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+
18081857
.. _stateless-routing:
18091858

18101859
Stateless Routes

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy