Routing in Symfony2 Routing in Symfony2 symfony symfony

Routing in Symfony2


I was looking through the cookbook for an answer to this, and think I've found it here. By default, all route parameters have a hidden requirement that they match any character except the / character ([^/]+), but this behaviour can be overridden with the requirements keyword, by forcing it to match any character.

The following should create a default route that catches all others - and as such, should come last in your routing config, as any following routes will never match. To ensure it matches "/" as well, a default value for the url parameter is included.

default_route:    pattern: /{url}    defaults: { _controller: AcmeBundle:Default:index, url: "index" }    requirements:        url: ".+"


I don't think it's possible with the standard routing component.Take a look to this bundle, it might help :https://github.com/hidenorigoto/DefaultRouteBundle


// Symfony2 PR10

in routing.yml:

default:    pattern:  /{_controller}

It enables you to use this kind of urls: http://localhost/MySuperBundle:MyController:myview