1. For example, how is the content displayed by frontedwebindex. php determined (index itself is not a page display) 2. For an app, it is often used to return to the home page. Where is the gethomeurl set? 1. For example, how to determine the content displayed by fronted/web/index. php (index itself is not displayed on the page)
2. For an app, it is often used to return to the home page. Where is the gethomeurl set?
Reply content:
1. For example, how to determine the content displayed by fronted/web/index. php (index itself is not displayed on the page)
2. For an app, it is often used to return to the home page. Where is the gethomeurl set?
I wanted to analyze the source code for a limited time.
Directly go to common/config/main. php
Return [// The default route goHome of the application will jump to 'defaultroute '=> 'controller/action' by default. Another way is to configure the urlManeger component 'components' => ['urlmanager' => [// This baseUrl will eventually decide the path of homeUrl, which is equivalent to specifying a domain name for the current application, and then the route of the real application jumps to 'baseurl' => 'HTTP: // www.test.com ', 'class' => 'yii \ web \ urlmanager', 'enableprettyurl' => true, 'showscriptname' => false, // 'suffix '=> 'path',],]
- Structure-controllers
$controllerObj->redirect();
$controllerObj->goHome();
Usage in the example. For more information, see api
In Yii, the default url should be like this:Http: // domain name/index. php? R = controllerName/actionName & Parameter 1 = value 1 & Parameter 2 = value 2
For fronted/web/index. php, visual testing, frontend should be the website front-end, that is, there is a web directory under the frontend directory, and the web directory contains the index. PHP file, which is the only front-end entry.
Back to the home page is not under control$this->redirect('/');
Is the translated URL http: // domain name?
PS: add the first point. The web directory should be the root directory of the web server. For example, if you want to access the actionTest () method under fooController, your url should be written as follows: http: // domain name/index. php? R = foo/test
The first problem is not very clear, and the second problem is that the returned home page can be used in the controller.$this->goHome();