I'm fairly new to yii, would like to know how to change the default page pra that instead of going to the index is directed to a page comingsoon I have.
Thanks for your time.
Method 1: Change view page rendered in SiteController.php's index action:
public function actionIndex() {
$this->render('index'); // change to "comingsoon"
}
Method 2: Let 404 error page display a coming soon message.
Method 3: Redirect to error page using URL manager rules in main.php:
'urlManager' => array(
'rules' => array(
'index'=>'site/index', // change "site/index" to "site/comingsoon"
...
Method 4: .htaccess
rewrite.
In your controller, just change the view to the location of the comingsoon view.
You can create a new controller with it's own view: comingsoon (see http://www.yiiframework.com/doc/guide/1.1/en/topics.gii).
Add this in: protected\config\main.php
'defaultController' => 'comingsoon',
The best way to do it is to specify defaultIndex as a class variable in your controller:
class SiteController extends Controller {
public $defaultIndex = 'comingSoon';
public function actionComingSoon() {
$this->renderPartial( ... etc .... );
}
You can specify which controller and action to be default. Add this to main.php
'defaultController'=>'site/index', // controller/action
There no need to edit anything on controller :)
If there is any problem I think you need to edit also the .htaccess (For Friendly Url) Cheers!
The best way is you can change urlmanager options like this by denoting the default page as empty charachter
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'enableStrictParsing' => false,
'rules' => [
'admin' => 'admin/index',
''=>'admin/index'