B
B
BonBon Slick2018-05-07 18:56:14
symfony
BonBon Slick, 2018-05-07 18:56:14

How to avoid duplicate routes in localization?

<route id="login" methods="POST|GET" path="{_locale}/login" controller="LogInController::authenticate">
   <requirement key="_locale">[a-z]{2}</requirement>
        <default key="_locale">`%app.default_locale%`</default>
<route>
// нужен дубликат
 <route id="login_default" methods="POST|GET" path="/login"   controller="LogInController::authenticate"/>

It turns out that if the user goes to a page where there is no locale, nothing stands between the domain name and /login, it will give an error No route found for "GET /login" , or 404

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
DevMan, 2018-05-07
@BonBonSlick

if the locale is not specified in the route and it is not in the session/cookies/etc, it should be set by default.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question