views:

100

answers:

1

For those wondering why Zend_Controller_Router_Route_Regex matches case-different routes, eg. hxxp://example.com/EN vs. hxxp://example.com/en, here's an explanation.

Zend_Controller_Router_Route_Regex is implicitly case insensitive. It is set in Zend_Controller_Router_Route_Regex::match() method. This is the piece of code that sets PCRE_CASELESS modifier:

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

I do not know if there is any way to suppress this behavior from inside of the regular expression. Any ideas?

A: 

You can extend Zend_Controller_Router_Route_Regex and just write a different match method, where the only difference would be in the regex pattern minus the i flag.

robertbasic