Yii2高級版本復制新項目會遇到下面的報錯信息:
exception 'yii\base\InvalidRouteException' with message 'Unable to resolve the request "site/error".' in /Users/yuzhiyuan/Documents/htdocs/yii-application/vendor/yiisoft/yii2/base/Module.php:461
Stack trace:
#0 /Users/yuzhiyuan/Documents/htdocs/yii-application/vendor/yiisoft/yii2/web/ErrorHandler.php(80): yii\base\Module->runAction('site/error')
#1 /Users/yuzhiyuan/Documents/htdocs/yii-application/vendor/yiisoft/yii2/base/ErrorHandler.php(95): yii\web\ErrorHandler->renderException(Object(yii\web\NotFoundHttpException))
#2 [internal function]: yii\base\ErrorHandler->handleException(Object(yii\web\NotFoundHttpException))
#3 {main}
Previous exception:
exception 'yii\base\InvalidRouteException' with message 'Unable to resolve the request "site/index".' in /Users/yuzhiyuan/Documents/htdocs/yii-application/vendor/yiisoft/yii2/base/Module.php:461
Stack trace:
#0 /Users/yuzhiyuan/Documents/htdocs/yii-application/vendor/yiisoft/yii2/web/Application.php(83): yii\base\Module->runAction('site/index', Array)
#1 /Users/yuzhiyuan/Documents/htdocs/yii-application/vendor/yiisoft/yii2/base/Application.php(375): yii\web\Application->handleRequest(Object(yii\web\Request))
#2 /Users/yuzhiyuan/Documents/htdocs/yii-application/mobile/web/index.php(18): yii\base\Application->run()
#3 {main}
Next exception 'yii\web\NotFoundHttpException' with message 'Page not found.' in /Users/yuzhiyuan/Documents/htdocs/yii-application/vendor/yiisoft/yii2/web/Application.php:95
Stack trace:
#0 /Users/yuzhiyuan/Documents/htdocs/yii-application/vendor/yiisoft/yii2/base/Application.php(375): yii\web\Application->handleRequest(Object(yii\web\Request))
#1 /Users/yuzhiyuan/Documents/htdocs/yii-application/mobile/web/index.php(18): yii\base\Application->run()
#2 {main}
解決辦法:
找到common\config\bootstrap.php
找到上面的文件,添加一個新的別名:
Yii::setAlias('應用名', dirname(dirname(__DIR__)) . '/目錄名’);
比如:Yii::setAlias('mobile', dirname(dirname(__DIR__)) . '/mobile’);
這樣就正常顯示了,媽的,讓我調整了一個下午。
Yii 用戶登陸機制 http://www.linuxidc.com/Linux/2015-01/111602.htm
Yii中引入js和css文件 http://www.linuxidc.com/Linux/2015-01/111603.htm
Yii 不完全解決方案 http://www.linuxidc.com/Linux/2015-01/111606.htm
Yii CGridView 基本使用 http://www.linuxidc.com/Linux/2015-01/111607.htm
Yii框架分布式緩存的實現方案 http://www.linuxidc.com/Linux/2015-02/113828.htm
Yii 的詳細介紹:請點這裡
Yii 的下載地址:請點這裡