我希望我的路由支持波斯字符,但是当在正则表达式路径中使用x {600} - \ x {6FF}时,应用会给我一个404错误(找不到页面)zend框架2使用UTF-8正则表达式路由
我ZF2路由配置:
'result' => array(
'type' => 'segment',
'options' => array(
'route' => '/Result[/:name]',
'constraints' => array(
'name' => '[\sa-zA-Z0-9_.-x{600}-\x{6FF}]*',
),
'defaults' => array(
'controller' => 'Result',
'action' => 'index',
),
),
),
,我添加u
结束在Zend的\的mvc \路由器正则表达式的\ HTTP \ Segment.php
if ($pathOffset !== null) {
$result = preg_match('(\G' . $regex . ')u', $path, $matches,null, $pathOffset);
} else {
$result = preg_match('(^' . $regex . '$)u', $path, $matches);
}
我的网址是这样的:
http://localhost/test/Result/A.8.کلمه
尝试''[\ sa-zA-Z0-9 _。\ x {600} - \ x {6FF} - ] *''。 –
我尝试使用上面的代码,但给我404错误 –
看来你需要将'rawurldecode($ path);'传递给'preg_match'。请尝试使用上述正则表达式。 –