yii2 高级模板中未找到 url

yii2 高级模板中未找到 url

我在本地主机和临时服务器上设置了我的项目。
但现在我想将我的项目移到ubuntu服务器上。
我试过了,但当我尝试找到我的项目时,它给了我The requested URL <PROJECT_NAME>/admin/site/login was not found on this server.
以下是我的main.php文件:

    <?php
    use \yii\web\Request;

    $params = array_merge(
        require(__DIR__ . '/../../common/config/params.php'),
        require(__DIR__ . '/../../common/config/params-local.php'),
        require(__DIR__ . '/params.php'),
        require(__DIR__ . '/params-local.php')
    );

    include(__DIR__ . '/constants.php');
    include(__DIR__ . '/print_arr_helper.php');
    $siteUrl = 'http://**IPADDRESS**/<PROJECT_NAME>/';
    return [
        'id' => 'app-backend',
        'basePath' => dirname(__DIR__),
        'controllerNamespace' => 'backend\controllers',
        'bootstrap' => ['log'],
        'modules' => [],
        'as beforeRequest' => [
            'class' => 'yii\filters\AccessControl',
            'rules' => [
                [
                    'actions' => ['login', 'error'],
                    'allow' => true,
                ],
                [
                    'allow' => true,
                    'roles' => ['@'],
                ],
            ],
        ],
        'components' => [
            'request'=>[
                'class' => 'common\components\Request',
                'web'=> '/backend/web',
                'adminUrl' => '/admin',
            ],
            'urlManager' => [
                'enablePrettyUrl' => true,
                'showScriptName' => false,
                'rules' =>  []
            ],
            'user' => [
                'identityClass' => 'app\models\User',
                'enableAutoLogin' => false,
            ],
            'log' => [
                'traceLevel' => YII_DEBUG ? 3 : 0,
                'targets' => [
                    [
                        'class' => 'yii\log\FileTarget',
                        'levels' => ['error', 'warning'],
                    ],
                ],
            ],
            'mongodb' => [
                'class' => '\yii\mongodb\Connection',
                'dsn' => 'mongodb://localhost:27017/<DB_NAME>',
            ],
            'errorHandler' => [
                'errorAction' => 'site/error',
            ],
        ],
        'params' => $params,

    ];
?>

这是我的.htaacess文件:

Options +FollowSymlinks
RewriteEngine On

# deal with admin first
RewriteCond %{REQUEST_URI} ^/<PROJRCT_NAME>/(admin)
RewriteRule ^admin/assets/(.*)$ backend/web/assets/$1 [L]
RewriteRule ^admin/css/(.*)$ backend/web/css/$1 [L]

RewriteCond %{REQUEST_URI} !^/<PROJRCT_NAME>/backend/web/(assets|css)/
RewriteCond %{REQUEST_URI} ^/<PROJRCT_NAME>/(admin)
RewriteRule ^.*$ backend/web/index.php [L]


RewriteCond %{REQUEST_URI} ^/<PROJRCT_NAME>/(assets|css)
RewriteRule ^assets/(.*)$ frontend/web/assets/$1 [L]
RewriteRule ^css/(.*)$ frontend/web/css/$1 [L]

RewriteCond %{REQUEST_URI} !^/<PROJRCT_NAME>/(frontend|backend|ws)/web/(assets|css)/
RewriteCond %{REQUEST_URI} !index.php
RewriteCond %{REQUEST_FILENAME} !-f [OR]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ frontend/web/index.php

backend/文件夹中.htaccess,如果我写入<IPADDRESS>/backend/URL它将被重定向到http://<IPADDRESS>/<PROJECT_NAME>/admin/site/login
有人可以帮忙吗?

答案1

通过修改/etc/apache2/apache2.conf文件解决了这个问题。对 进行了更改line no:166。表格NoneAll

相关内容