I'm having troubles with (german) special characters in URIs and want to try to resolve it with a RegEx Route and a PCRE pattern modifier for UTF-8 u
.
'router' => array(
'routes' => array(
// ...
'city' => array(
'type' => 'regex',
'options' => array(
'regex' => '/catalog/(?<city>[a-zA-Z0-9_-äöüÄÖÜß]*)\/u',
'defaults' => array(
'controller' => 'Catalog\Controller\Catalog',
'action' => 'list-sports',
),
'spec' => '/catalog/%city%',
),
'may_terminate' => true,
),
),
),
But when I set it, the route stopps to work at all (error 404) -- neither for URIs with nor to ones without special characters.
How to set the modifier correctly?
Since I already had this open here's a handler that solves the problem.
Assuming you place the file in
Application/Mvc/Router/Http/UnicodeRegex
your route definition should look like thisWell,
I guess you can solve it as easily as many other ones had this same problem. So take a look at some of them:
UTF-8 in * regular expressions
There uses the following modifiers like
\\s
,\\p{L}
, and\\u
to help you. I hope it solves! Good luck.Edit
See my own test:
Can you realize?
Edit 2
It can be better for you!