The redirection works, but it is not the solution I’m looking for.
The redirection responds with a http 302 to the browser, indicating what URL should be loaded.
The browser parses the http 302 response and issues a new request with the URL indicated in the http-header LOCATION.
This does load the mainpage.
BUT to me, this is one http request too much. Why should the browser do the redirection ?
The server should just render the mainpage. And that is what I want, call SiteController.actionIndex(). The problem is I’m not very familiair with PHP/YII. My solution with instantiating SiteController results in the lazyloader complaining it can’t find SiteController.php.
Maybe I should refrase my question into:
How do I instantiate SiteController from within MyController ?
If I have an instance, I can call function actionIndex() and my problem is solved.
You should not be afraid of redirects. They are a standard way of doing a clean page refresh. With HTTP 1.1’s KeepAlive connections there isn’t even a new connection created. And the additional roundrip time shouldn’t even be noticable as no content needs to be transferred on the first response.
Moreover you’ll very soon get problems with POST requests and users clicking the reload button. (“Should the POST data be sent again?”).