symfony2 use multiple url pattern for a single Controller Action using regular expression
Do you mean placeholders with requirements?
blog: pattern: /blog/{page} defaults: { _controller: AcmeBlogBundle:Blog:index, page: 1 } requirements: page: \d+
Here you have multiple routes defined by a placeholder, validated by regular expressions going to the same controller action.
Edit:
Each part of the url can be a placeholder.
blog: pattern: /{type}/{page} defaults: { _controller: AcmeBlogBundle:Blog:index, page: 1 } requirements: type: blog|articles page: \d+
Annotations example for routes with parameters :
/** * @Route("/shops/{page}", name="shops") * @Route("/shops/town/{town}/{page}", name="shops_town") * @Route("/shops/department/{department}/{page}", name="shops_department") */public function shopsAction(Town $town = null, Department $department = null, $page = 1){ ... }
Then generate route in twig like this :
{{ path('shops_town') }}
or
{{ path('shops_town', {'town': town.id}) }}
or
{{ path('shops_department', {'department': department.id}) }}