Prefix route automatically adds trailing slash if a pattern is empty.
Example:
In the Routing.xml:
import resource="@AcmeTestBundle/Controller/TestController.php" prefix="/test" type="annotation"
In the FrameworkExtraBundle annotations:
Whenever you go to /test SF2 will automatically redirect it to /test/
If you add a dummy variable however, and give it a default value it is not being redirected, example:
The behavior is indeed correct. Let me explain why.
First, a /
is always prepended to a route if it is not already the case. So, an empty route is equivalent to /
and when you define a {dummy}
route pattern, this is equivalent to /{dummy}
.
When you use /test
as a prefix, you are mounting all routes under a /test
"directory", so all defined routes are "inside" this "directory".
For the first case, and empty string or /
means the root of the directory, and if you omit the /
, Symfony will automatically redirects you to this page (the same behavior as Apache), but when you use /{dummy}
, you are not referencing the root anymore (even if there is a default value), so the redirection does not occur.