I have module structure in my Yii 2.0 application, so I need to call things like
"<controller:\w+>/<action:\w+>" => "<controller>/<controller>/<action>"
I found better solution. PCRE supports modifier "?J" that allows duplicate names for subpatterns. All we need is to add this modifier to our pattern that Yii will use for parsing url. Unfortunately we have to add it manually, in yii/web/UrlRule change line:
$this->_routeRule = '#^' . strtr($this->route, $tr2) . '$#u';
$this->_routeRule = '#^(?J)' . strtr($this->route, $tr2) . '$#u';