I’m trying to move a Yii application from a development machine to Amazon EC2 instance. I’m getting an exception on the Amazon server related to CUrlManager which is:
The URL pattern "<controller:\w+>/<id:\d+>" for route "<controller>/view" is not a valid regular expression.
After a bit of trial and error, i did figure out one thing, that:
Options +FollowSymLinks
has nothing to do with this problem.
Removing the ‘rules’ array from the ‘urlManager’ component removes this error, while keeping the ‘path’ format working, so my urlManager looks like this right now:
Outrage, thank you for the reply. i’m just running the "Amazon Linux AMI 2012.03 " . php version is 5.3.15 , my local machine has 5.3.10 and it works fine locally. I’ll try with a different distro and see how it goes.
This error is thrown in line 700 in CUrlManager.php by the CUrlRule class’s ‘__construct()’ method :
if(YII_DEBUG && @preg_match($this->pattern,'test')===false)
throw new CException(Yii::t('yii','The URL pattern "{pattern}" for route "{route}" is not a valid regular expression. Also this pattern is {thispatt}',
array('{route}'=>$route,'{pattern}'=>$pattern,'{thispatt}'=>$this->pattern)));
// i added $this->pattern to the message to know the pattern that errors
After the above modification i get the error message as:
The URL pattern "<controller:\w+>/<id:\d+>" for route "<controller>/view" is not a valid regular expression. Also this pattern is /^(?P<controller>\w+)\/(?P<id>\d+)\/$/u
Any hints? (Obviously something to do with the preg_match, but what?)
Funnily enough, a restart solved this problem! I hadn’t restarted my ami since i started it, i had also applied quite a few updates since then. So i guess some update required a restart, which was effecting this. Wish i knew what it was though.
I have the same issue on my (shared) webserver (php 5.4.16). However only that check fails, I thinking to disable that check on my webserver. Could it hurt?