它在我的lohalhost中运行良好,当我尝试在服务器上运行时,出现了此错误。
在index.php中
<?php defined('YII_DEBUG') or define('YII_DEBUG', true); defined('YII_ENV') or define('YII_ENV', 'dev');
require(__DIR__ . '/_protected/vendor/autoload.php'); require(__DIR__ . '/_protected/vendor/yiisoft/yii2/Yii.php'); require(__DIR__ . '/_protected/common/config/bootstrap.php'); require(__DIR__ . '/_protected/frontend/config/bootstrap.php');
$config = yiihelpersArrayHelper::merge(
require(__DIR__ . '/_protected/common/config/main.php'),
require(__DIR__ . '/_protected/common/config/main-local.php'),
require(__DIR__ . '/_protected/frontend/config/main.php'),
require(__DIR__ . '/_protected/frontend/config/main-local.php') );
$application = new yiiwebApplication($config); $application->run();
.htaccess
RewriteEngine on
# hide files and folders
RedirectMatch 404 /_protected
RedirectMatch 404 /.git
RedirectMatch 404 /composer.
RedirectMatch 404 /.bowerrc
# If a directory or a file exists, use the request directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Otherwise forward the request to index.php
RewriteRule . index.php
如果您使用apache设置DocumentRoot/var/www/frontend/web
并将.htaccess文件添加到/var/www/frontend/web中,内容为
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php