@@ -147,6 +147,53 @@ suppose you want to prefix all application routes with ``/site`` (e.g.
147147 The path of each route being loaded from the new routing resource will now
148148be prefixed with the string ``/site ``.
149149
150+ ..note ::
151+
152+ If any of the prefixed routes defines an empty path, Symfony adds a trailing
153+ slash to it. In the previous example, an empty path prefixed with ``/site ``
154+ will result in the ``/site/ `` URL. If you want to avoid this behavior, set
155+ the ``trailing_slash_on_root `` option to ``false ``:
156+
157+ ..configuration-block ::
158+
159+ ..code-block ::yaml
160+
161+ # config/routes.yaml
162+ controllers :
163+ resource :' ../src/Controller/'
164+ type :annotation
165+ prefix :/site
166+ trailing_slash_on_root :false
167+
168+ ..code-block ::xml
169+
170+ <!-- config/routes.xml-->
171+ <?xml version =" 1.0" encoding =" UTF-8" ?>
172+ <routes xmlns =" http://symfony.com/schema/routing"
173+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
174+ xsi : schemaLocation =" http://symfony.com/schema/routing
175+ http://symfony.com/schema/routing/routing-1.0.xsd" >
176+
177+ <import
178+ resource =" ../src/Controller/"
179+ type =" annotation"
180+ prefix =" /site"
181+ trailing-slash-on-root =" false" />
182+ </routes >
183+
184+ ..code-block ::php
185+
186+ // config/routes.php
187+ use Symfony\Component\Routing\RouteCollection;
188+
189+ $app = $loader->import('../src/Controller/', 'annotation');
190+ // the second argument is the $trailingSlashOnRoot option
191+ $app->addPrefix('/site', false);
192+ // ...
193+
194+ ..versionadded ::4.1
195+ The ``trailing_slash_on_root `` option was introduced in Symfony 4.1.
196+
150197Prefixing the Names of Imported Routes
151198~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
152199