Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e5b3fff

Browse filesBrowse files
author
Olivier Dolbeau
committed
Explain host per locale
1 parent ecf8815 commit e5b3fff
Copy full SHA for e5b3fff

File tree

1 file changed

+49
-0
lines changed
Filter options

1 file changed

+49
-0
lines changed

‎routing.rst

Copy file name to clipboardExpand all lines: routing.rst
+49Lines 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.nl',
1852+
'nl' => 'https://www.symfony.nl'
1853+
])
1854+
;
1855+
};
1856+
18081857
.. _stateless-routing:
18091858

18101859
Stateless Routes

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.