I'm currently developing an application using Symfony 2 and would like my routes to be case-insensitive.
I've included an example route. This only matches /some_url/. I'd like this to match any variation on that pattern. eg. /Some_url/, /SOME_URL/ etc...
some_route:
pattern: /some_url/
defaults: { _controller: Bundle:Controller:Action }
Does anyone know how I can achieve this?
try this:
some_route:
pattern: /{some_url}/
defaults: { _controller: Bundle:Controller:Action }
requirements:
some_url: (?i:some_url)
but as already mentioned in the comments, this is a bad practice
try this
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 some routes for diferents case sensitive math, and redirect at some route with this instructions in the default property
defaults: { _controller: FrameworkBundle:Redirect:redirect, route: some_route }
I hope this helps! ...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.