简体   繁体   中英

Same project create two type SEO friendly url on Yii

I'm newbie on Yii, I'm facing some difficulties on create Yii SEO Friendly url.

My code is below:

echo CHtml::link($Menu->label, array('articles/view', 'id'=>$Menu->link,

This solution below config/main:

return array(
// ......
'components'=>array(
    // ......
    'urlManager'=>array(
        'urlFormat'=>'path',
        'rules'=>array(
            'articles/<id:\d+>-<t:.+>'=>'articles/view',
            // .......
        ),
    ),
  ),
);

But this project created another url like below:

articles/view&id=".$menu['items'][$itemId]['link'].

How to create SEO friendly url on this type link.

Summery

Same project create two type SEO friendly url

Thanks

Try this,

"articles/view/<id:([a-zA-Z0-9$&,':=?|.^*()%~!-]+)>" => "articles/view",

and call url as /articles/view/id/1

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