I would like to construct the following URI's using a single route pattern
1 hello/first.format
2 hello/first
3 hello/first/last.format
4 hello/first/last
where first is required and last and format are optional.
this is what I have tried:
hello-route:
pattern: /hello/{fist_name}/{last_name}.{_format}
defaults: { _controller: AcmeHelloBundle:Default:index, last_name:Default, _format:html}
requirements:
_format: html|rss|json
first_name: \w+
last_name: \w+
But is not correct as it matches 2, 3, and 4 but not 1. 1 will not fail, but it will match {first_name} as "first.format" despite the requirement.
How can I do this using basic routing?