在前端的frontend的web目录下创建后台admin文件夹,然后从backend的web的index.php文件复制到admin里面;
修改index.php文件代码:(目录文件:frontend/web/admin/index.php):
<?php
defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'dev');
require __DIR__ . '/../../../vendor/autoload.php';
require __DIR__ . '/../../../vendor/yiisoft/yii2/Yii.php';
require __DIR__ . '/../../../common/config/bootstrap.php';
require __DIR__ . '/../../../backend/config/bootstrap.php';
$config = yii\helpers\ArrayHelper::merge(
require __DIR__ . '/../../../common/config/main.php',
require __DIR__ . '/../../../common/config/main-local.php',
require __DIR__ . '/../../../backend/config/main.php',
require __DIR__ . '/../../../backend/config/main-local.php'
);
(new yii\web\Application($config))->run();
这样前后台的唯一入口都在这里了,这样就可以用域名 http://ww.你的域名.com/访问前台;
用域名 http://ww.你的域名.com/admin
访问你的后台了