简体   繁体   中英

Can I access urlManager Rules when urlFormat is 'get' in yii?

I have a problem with my YII urlManager. urlManager Rules are not applying when urlFormat is 'get'. Here my urlManager code

'urlManager' => array(
   'urlFormat' => 'get',
   'showScriptName' => true,
   //'appendParams'=>false,
   'hostInfo'=>'My Base Url',
   'secureHostInfo'=>'My Secured Base Url',
   'ssl'=>false,
   'class'=>'myUrlManager',
   'rules' => array(
       array(
           'class' => 'application.components.MyBaseUrlManager',
           'connectionID' => 'db',
       ),
       '<controller:\w+>/<action:\w+>/*'=>'<controller>/<action>',
    ),
),

Here myUrlManager is extend class from CUrlManager and MyBaseUrlManager is extended class from CBaseUrlRule.

Is it possible to access the rules of urlManager when the urlformat is 'get'?

Thanks in Advance

You can access rules but these aren't processed or applied. See https://github.com/yiisoft/yii/blob/master/framework/web/CUrlManager.php#L214 :

protected function processRules()
{
    if(empty($this->rules) || $this->getUrlFormat()===self::GET_FORMAT)
        return;
    ...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM