Yii advanced url rewrite

前端 未结 3 1113
Happy的楠姐
Happy的楠姐 2021-02-02 03:01

pay attention to that ANYTHING_ELSE So, I have my controllers and actions that I want to behave as normal in response to examples like this:

// for UserContoller         


        
3条回答
  •  执念已碎
    2021-02-02 03:03

    If I've realized you correctly, you may use something like this:

      'rules' => array(
        //You should define all the controllers exactly:
        '/' => '/',
        //Or more complicated rule:
        '/(turismo|visita|travel)/' => array('visit/page', 'urlSuffix' => '.html'),
    
        //After that you can process all remaining urls as you want:
        '' => array('blog/view', 'urlSuffix' => '.html'),
      ),
    

    And the controller:

    class BlogController extends Controller
    {
        public function actionView($alias)
        {
            echo $alias;
        }
    }
    

提交回复
热议问题