2

I've got a very strange problem. I have some simple routes configured which worked on my local server (PHP 5.3 and 5.4, both work fine) but on the deployment server (PHP 5.3.23) they failed, so I even switched to the default routes preconfigured by Yii (even though I'm pretty sure mine was correct), but they also fail with the following exception The URL pattern "<controller:\w+>/<id:\d+>" for route "<controller>/view" is not a valid regular expression.

Here are the routes:

'urlManager'=>array(
    'urlFormat'=>'path',
    'rules'=>array(
        //'^$' => 'site/index',
        //'<view:[\w\-\_\d]+>' => 'site/paged',
        '<controller:\w+>/<id:\d+>'=>'<controller>/view',
        '<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
        '<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
    ),
    'showScriptName' => true,
),

as you can see I've commented out my two routes to make sure I didn't made some stupid mistake.

What is wrong?


here's the backtrace if anyone's interested http://i.imgur.com/z0HtioQ.png

4

2 回答 2

1

Well, it seems that yii complains on the part with <controller>/view. For url rules you can use special placeholders with _ prefix, for module, controller, action - respectively _m, _c, _a. In your case you could use something like that:

'urlManager'=>array(
    'urlFormat'=>'path',
    'rules'=>array(
        //'^$' => 'site/index',
        //'<view:[\w\-\_\d]+>' => 'site/paged',
        '<_c>/<id:\d+>'=>'<_c>/view',
        '<_c>/<_a>/<id:\d+>'=>'<_c>/<_a>',
        '<_c>/<_a>'=>'<_c>/<_a>',
    ),
    'showScriptName' => true,
),
于 2013-08-08T13:41:25.203 回答
1

After short investigation, this is what I've found.

preg_match() Compilation failed: unknown option bit(s) set at offset 0

It seems that the problem is that my config file is UTF-8. The solution is to update PHP & PCRE.

于 2013-08-13T20:58:23.627 回答