2010-06-04 110 views
2

對於那些想知道爲什麼Zend_Controller_Router_Route_Regex匹配大小寫不同的路由,例如。 hxxp://example.com/EN與hxxp://example.com/en,這裏有一個解釋。Zend_Controller_Router_Route_Regex不區分大小寫

Zend_Controller_Router_Route_Regex隱含不區分大小寫。它在Zend_Controller_Router_Route_Regex::match()方法中設置。這是一段代碼,設置PCRE_CASELESS修改:

if (!$partial) { 
$path = trim(urldecode($path), '/'); 
$regex = '#^' . $this->_regex . '$#i'; 
} else { 
$regex = '#^' . $this->_regex . '#i'; 
} 

我不知道是否有任何辦法從正則表達式的內抑制這種行爲。有任何想法嗎?

回答

1

您可以擴展Zend_Controller_Router_Route_Regex並只寫一個不同的match方法,其中唯一的區別是在正則表達式模式中減去i標誌。