Symfony 2 case insensitive

I am currently developing an application using Symfony 2 and would like my routes to be case insensitive.

I included an example route. This only matches / some _url /. I would like it to fit any version of this template. eg. / Some _url /, / SOME_URL / etc ...

some_route: pattern: /some_url/ defaults: { _controller: Bundle:Controller:Action } 

Does anyone know how I can achieve this?

+4
source share
2 answers

try the following:

 some_route: pattern: /{some_url}/ defaults: { _controller: Bundle:Controller:Action } requirements: some_url: (?i:some_url) 

but as mentioned in the comments, this is bad practice.

+7
source

try it

  some_route: pattern: /some_url/ defaults: { _controller: Bundle:Controller:Action } _Some_route: pattern: /Some_url/ defaults: { _controller: FrameworkBundle:Redirect:redirect, route: some_route } __SOME_route: pattern: /SOME_URL/ defaults: { _controller: FrameworkBundle:Redirect:redirect, route: some_route } 

You can create multiple routes for different maths case-sensitive and redirect to some route using these instructions in the default property

 defaults: { _controller: FrameworkBundle:Redirect:redirect, route: some_route } 

Hope this helps! ...

0
source

All Articles