0

I set my project on localhost and on staging server.
But now i want to move my project on ubuntu server.
I tried it but when i try to locate my project it is giving me The requested URL <PROJECT_NAME>/admin/site/login was not found on this server.
Here is my main.php file:

    <?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,

    ];
?>

Here is my .htaacess file:

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

In backend/ forlders .htaccess, if i write <IPADDRESS>/backend/ in URL then it will be redirect to http://<IPADDRESS>/<PROJECT_NAME>/admin/site/login.
Can anyone help?

1

It is solved by making changes in /etc/apache2/apache2.conf file. Made changes on line no:166. Form None to All.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.