Why in case 1 application accepts also /contact url? I have clearly expect /contact/ url not contact/
/contact
means that you are leaving out the anything
parameter which will be in this case null
.
/contact/
means that you are NOT leaving out the anything
parameter. In this case NotFoundHttpException
should be thrown, because you haven't provided any value for anything
parameter.
Why in case 2 applications accepts also /contact url making redirection for it to /contact/
It is behaviour of Symfony2 routing component, there can't be really told more about it.
Why behaviour is different in case 1 and case 2
Because in case 1 there is a parameter in the route. The parameter has although a default value. In case 2 there is no parameter in the route.
Is it possible to change this behaviour - for example not accept at all /contact in my case
Yes, for example make the anything
parameter to be mandatory, not optional.
Does Symfony do such "tricks" for all urls (also with extension as for example I define it works for /test.html and Symfony makes it work also for /test.html/ ) or only for those without extension
Behaviour of the routing component is consistent, it does not matter if you use test
or test.html
.
Where can I read a bit more about such cases?
There won't be many sources regarding this, but you can always check out source code of the routing component.
However, documentation to routing component can be found here Routing.