Route Requirements in symfony2:
You can add regex requirements that the requested url needs to match to get resolved as a certain route:
# This example allows only digits (\d+) for {category}
blog:
path: /blog/{category}
defaults: { _controller: AcmeBlogBundle:Blog:index, category: 1 }
requirements:
category: \d+
Exluding routes containing dots:
# matches only routes not containing a dot
blog:
path: /blog/{category}
defaults: { _controller: AcmeBlogBundle:Blog:index, category: 1 }
requirements:
category: ^[^\.]*$
explanation:
^
- beginning of string[^\.]*
- any character except.
, any number of repetitions$
- end of string