using url manager in yii to change url to seo friendly

前端 未结 2 1690
傲寒
傲寒 2020-12-30 17:16

How can I convert these URL to SEO friendly URL I tried Url manager in yii but didn\'t get the proper result is there any good tutorial regarding url manager



        
2条回答
  •  执念已碎
    2020-12-30 17:34

    In Yii we can create urls dynamically For eg.

    $url=$this->createUrl($route,$params);
    $route='post/read'.
    $params=array('id'=>100)
    

    we would obtain the following URL:

    /index.php?r=post/read&id=100
    

    To change the URL format, we should configure the urlManager application component so that createUrl can automatically switch to the new format and the application can properly understand the new URLs:

    array(
        ......
        'components'=>array(
            ......
            'urlManager'=>array(
                'urlFormat'=>'path',
            ),
        ),
    );
    

    WE will obtain this

    /index.php/post/read/id/100
    

    You can refer this link for user friendly urls in yii http://www.yiiframework.com/doc/guide/1.1/en/topics.url

提交回复
热议问题