运行我的Yii2应用程序时遇到问题。它在我的计算机上工作正常,即localhost但是当从git lab中取出时它没有运行。错误是 -
An Error occurred while handling another error exception 'yii\base\InvalidRouteException' with message 'Unable to resolve the request: site/error' in /var/www/html/jd4test/vendor/yiisoft/yii2/base/Controller.php:127 Stack trace:
#0 /var/www/html/jd4test/vendor/yiisoft/yii2/base/Module.php(523): yii\base\Controller->runAction('error', Array)
#1 /var/www/html/jd4test/vendor/yiisoft/yii2/web/ErrorHandler.php(95): yii\base\Module->runAction('site/error')
#2 /var/www/html/jd4test/vendor/yiisoft/yii2/base/ErrorHandler.php(111): yii\web\ErrorHandler->renderException(Object(yii\web\NotFoundHttpException))
#3 [internal function]: yii\base\ErrorHandler->handleException(Object(yii\web\NotFoundHttpException))
#4 {main} Previous exception: exception 'yii\base\InvalidRouteException' with message 'Unable to resolve the request: site/' in /var/www/html/jd4test/vendor/yiisoft/yii2/base/Controller.php:127 Stack trace:
#0 /var/www/html/jd4test/vendor/yiisoft/yii2/base/Module.php(523): yii\base\Controller->runAction('', Array)
#1 /var/www/html/jd4test/vendor/yiisoft/yii2/web/Application.php(102): yii\base\Module->runAction('', Array)
#2 /var/www/html/jd4test/vendor/yiisoft/yii2/base/Application.php(380): yii\web\Application->handleRequest(Object(yii\web\Request))
#3 /var/www/html/jd4test/web/index.php(12): yii\base\Application->run()
#4 {main}
Next exception 'yii\web\NotFoundHttpException' with message 'Page not found.' in /var/www/html/jd4test/vendor/yiisoft/yii2/web/Application.php:114 Stack trace:
#0 /var/www/html/jd4test/vendor/yiisoft/yii2/base/Application.php(380): yii\web\Application->handleRequest(Object(yii\web\Request))
#1 /var/www/html/jd4test/web/index.php(12): yii\base\Application->run()
#2 {main}
现在在它在本地主机上工作的状态之后发生了一些变化,就像web.php配置文件中添加的规则一样 -
'urlManager' => [
'class' => 'yii\web\UrlManager',
// Disable index.php
'showScriptName' => false,
// Disable r= routes
'enablePrettyUrl' => true,
'rules' => array(
'<controller:\w+>/<id:\d+>' => '<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
'<controller:\w+>/<action:\w+>' => '<controller>/<action>',
),
],
还添加了.htaccess文件,
RewriteEngine on
# If a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Otherwise forward it to index.php
RewriteRule . index.php
PLZ帮助我,没有这个项目工作正常,但考虑到我在这里添加的其他文件和代码是必要的。我该怎么办呢?
答案 0 :(得分:0)
它清楚地说invalidRouteException
。检查您的网址,确保您已从git正确地将其拉到共享主机。