Search code examples
phpregexurlyiiyii-url-manager

Yii UrlManager Action OR Controller


Is it possible in Yii UrlManager rules to set rule OR site/? For example there's "action Contacts in SiteController" and "controller MediController". Yii must use action from SiteController if it exists or user MediaController/index if not.


Solution

  • In UrlManager, It will search from Top to Down.

    So upto my knowledge, you can not define two CONTROLLER/ACTION for same Url alias.

    But you can use controller forward in siteController. If your condition not satisfy then forward to mediaController.

    $this->forward('media/index');
    

    Hope helps !!