Skip to content

[Routing] Explain host per locale #15042

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 21, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions routing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2206,6 +2206,53 @@ with a locale. This can be done by defining a different prefix for each locale
;
};

Another common requirement is to host the website on a different domain
according to the locale. This can be done by defining a different host for each
locale.

.. versionadded:: 5.1

The ability to define an array of hosts was introduced in Symfony 5.1.

.. configuration-block::

.. code-block:: yaml

# config/routes/annotations.yaml
controllers:
resource: '../../src/Controller/'
type: annotation
host:
en: 'https://www.symfony.com'
nl: 'https://www.symfony.nl'

.. code-block:: xml

<!-- config/routes/annotations.xml -->
<?xml version="1.0" encoding="UTF-8" ?>
<routes xmlns="http://symfony.com/schema/routing"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/routing
https://symfony.com/schema/routing/routing-1.0.xsd">
<import resource="../../src/Controller/" type="annotation">
<host locale="en">https://www.symfony.com</host>
<host locale="nl">https://www.symfony.nl</host>
</import>
</routes>

.. code-block:: php

// config/routes/annotations.php
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;
return function (RoutingConfigurator $routes) {
$routes->import('../../src/Controller/', 'annotation')
->host([
'en' => 'https://www.symfony.com',
'nl' => 'https://www.symfony.nl'
])
;
};

.. _stateless-routing:

Stateless Routes
Expand Down
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