Change default page in yii

I am new to yii, I would like to know how to change the default page, that instead of going to the index, it will be redirected to the page that I have.

Thank you for your time.

+5
source share
6 answers

Method 1: Change the view page displayed in the SiteController.php index action:

public function actionIndex() {
    $this->render('index'); // change to "comingsoon"
}

Method 2. Give the 404 error page the next message.

Method 3: Redirect to the error page using the URL management rules in main.php:

'urlManager' => array(
    'rules' => array(
        'index'=>'site/index', // change "site/index" to "site/comingsoon"
        ...

Method 4: .htaccessrewrite.

+2
source

: comingsoon (. http://www.yiiframework.com/doc/guide/1.1/en/topics.gii).

: \Config\main.php

'defaultController' => 'comingsoon', 
+4

, . main.php

'defaultController'=>'site/index', // controller/action

- :)

- , , .htaccess ( URL) !

+2

.

0

- defaultIndex :

class SiteController extends Controller {
    public $defaultIndex = 'comingSoon';

    public function actionComingSoon() {

        $this->renderPartial( ... etc .... );

    }
0

- urlmanager, , charachter

'urlManager' => [
    'enablePrettyUrl' => true,
    'showScriptName' => false,
    'enableStrictParsing' => false,
    'rules' => [
        'admin' => 'admin/index',
        ''=>'admin/index'
0

All Articles