Symfony2 routing: Allow dots in URL

Eneko
enekochan
Published in
1 min readJan 20, 2014

I have one route in my app that must have a text and a dot followed by a format. For example:

As you can see it’s an url that can contain dots before the dot that splits the {text} and the {_format} parts.

To make this work you have to define the route in routing.yml using a regexp for {text} this way:

dotted_url:
pattern: /image/{text}.{_format}
defaults: { _controller: AcmeDemoBundle:Demo:image, _format: png }
requirements:
_format: png|jpg
text: .+

Ref: http://stackoverflow.com/questions/18098583/error-in-symfony2-when-url-cointains-dot

--

--