0

I'm trying to completely manage my page with .htaccess file and two links/button or redirect:

  • one from frontend to backend
  • one from backend to frontend

Hope that is clearly enough.

My environment is DEV as I'm working localy if that is so difference.

All I tried:

And I'm a bit confused with .htaccess files and urlManager so appreciate any help a lot.

Let's check the files :

DIRECTORY ROOT & COMMON


/.htacces

#prevent directory listing
Options -Indexes
IndexIgnore */*

#follow symbolic links
Options FollowSymlinks
RewriteEngine on
RewriteRule ^admin(/.+)?$ backend/web/$1 [L,PT]
RewriteRule ^(.+)?$ frontend/web

/common/config/main.php

  return [
    'aliases' => [
        '@bower' => '@vendor/bower-asset',
        '@npm'   => '@vendor/npm-asset',
    ],
    'vendorPath' => dirname(dirname(__DIR__)) . '/vendor',
    'components' => [
        'cache' => [
            'class' => 'yii\caching\FileCache',
        ],
    ],
];

FRONTEND & FRONTEND CONTROLLER


/frontend/.htacces

RewriteEngine on

#if directory or a file exist, use the request directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

#otherwise, forward to index.php
RewriteRule . index.php

/frontend/config/main.php

$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'
);

return [
    'id' => 'app-frontend',
    'basePath' => dirname(__DIR__),
    'bootstrap' => ['log'],
    'controllerNamespace' => 'frontend\controllers',
    'components' => [
        'request' => [
            'csrfParam' => '_csrf-frontend',
        ],
        // main - used to generate and parse URLs to frontend from 
        'urlManager' => [
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            'baseUrl' => '/frontend/web',
            'rules' => [
                '/' => 'site/index',
                'home' => 'site/home',
                'about' => 'site/about',
                'moje-prace' => 'site/moje-prace',
                'umow-wizyte' => 'rezerwacje/create',
                'contact' => 'site/contact',
                'login' => 'site/login',
                'signup' => '/site/signup',
            ],
        ],
// slave - used to generate URLs to backend from frontend app
        'urlManagerBackend' => [
            'class' => 'yii\web\urlManager',
            'baseUrl' => '/admin',
            'enablePrettyUrl' => true,
            'showScriptName' => false,
        ]

        'user' => [
            'identityClass' => 'common\models\User',
            'enableAutoLogin' => true,
            'identityCookie' => ['name' => '_identity-frontend', 'httpOnly' => true],
        ],
        'session' => [
            // this is the name of the session cookie used for login on the frontend
            'name' => 'advanced-frontend',
        ],
        'log' => [
            'traceLevel' => YII_DEBUG ? 3 : 0,
            'targets' => [
                [
                    'class' => 'yii\log\FileTarget',
                    'levels' => ['error', 'warning'],
                ],
            ],
        ],
        'errorHandler' => [
            'errorAction' => 'site/error',
        ],
    ],
    'params' => $params,
];

/frontend/controllers/SiteController.php

namespace frontend\controllers;

use Yii;
use yii\base\InvalidParamException;
use yii\web\BadRequestHttpException;
use yii\web\Controller;
use yii\filters\VerbFilter;
use yii\filters\AccessControl;
use common\models\LoginForm;
use frontend\models\PasswordResetRequestForm;
use frontend\models\ResetPasswordForm;
use frontend\models\SignupForm;
use frontend\models\ContactForm;

/**
 * Site controller
 */
class SiteController extends Controller
{

    /**
     * {@inheritdoc}
     */
    public function behaviors()
    {
        return [
            'access' => [
                'class' => AccessControl::className(),
                'only' => ['logout', 'index', 'home', 'contact', 'about'],
                'rules' => [
                    [
                        'actions' => ['logout'],
                        'allow' => true,
                        'roles' => ['@'],
                    ],
                    [
                        'actions' => ['index'],
                        'allow' => true,
                        'roles' => ['@'],
                    ],
                    [
                        'actions' => ['home'],
                        'allow' => true,
                        'roles' => ['@'],
                    ],
                    [
                        'actions' => ['contact'],
                        'allow' => true,
                        'roles' => ['@'],
                    ],
                    [
                        'actions' => ['about'],
                        'allow' => true,
                        'roles' => ['@'],
                    ],
                ],
            ],
            'verbs' => [
                'class' => VerbFilter::className(),
                'actions' => [
                    'logout' => ['post'],
                ],
            ],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function actions()
    {
        return [
            'error' => [
                'class' => 'yii\web\ErrorAction',
            ],
            'captcha' => [
                'class' => 'yii\captcha\CaptchaAction',
                'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : null,
            ],
        ];
    }


    /**
     * Displays homepage.
     *
     * @return mixed
     */
    public function actionIndex()
    {
        if (!Yii::$app->user->isGuest) {

            $this->layout = 'main';

            return $this->render('home');
        }

        return $this->goHome();
    }


    /**
     * Displays about page.
     *
     * @return mixed
     */
    public function actionHome()
    {
        return $this->render('home');
    }


    /**
     * Logs in a user.
     *
     * @return mixed
     */
    public function actionLogin()
    {
        $this->layout = 'welcome';

        if (!Yii::$app->user->isGuest) {

            $this->layout = 'main';

            return $this->render('home');
        }

        $model = new LoginForm();
        if ($model->load(Yii::$app->request->post()) && $model->login()) {

            $this->layout = 'main';

            return $this->render('home');
        }
        else {
            $model->password = '';

            return $this->render('login', [
                'model' => $model,
            ]);
        }
    }

    /**
     * Logs out the current user.
     *
     * @return mixed
     */
    public function actionLogout()
    {
        Yii::$app->user->logout();

        return $this->goHome();
    }

    /**
     * Displays contact page.
     *
     * @return mixed
     */
    public function actionContact()
    {
        $model = new ContactForm();
        if ($model->load(Yii::$app->request->post()) && $model->validate()) {

            if ($model->sendEmail(Yii::$app->params['adminEmail'])) {

                Yii::$app->session->setFlash('success', 'Thank you for contacting us. We will respond to you as soon as possible.');
            }
            else {

                Yii::$app->session->setFlash('error', 'There was an error sending your message.');
            }

            return $this->refresh();
        }
        else {
            return $this->render('contact', [
                'model' => $model,
            ]);
        }
    }

    /**
     * Displays about page.
     *
     * @return mixed
     */
    public function actionAbout()
    {
        return $this->render('about');
    }

    /**
     * Signs user up.
     *
     * @return mixed
     */
    public function actionSignup()
    {

        $this->layout = 'welcome';

        $model = new SignupForm();

        if ($model->load(Yii::$app->request->post())) {

            if ($user = $model->signup()) {

                if (Yii::$app->getUser()->login($user)) {

                    $this->layout = 'main';

                    return $this->actionHome();
                }
            }
        }

        return $this->render('signup', [
            'model' => $model,
        ]);
    }

BACKEND & BACKEND CONTROLLER


/backend/.htacces

RewriteEngine on

#if directory or a file exist, use the request directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

#otherwise, forward to index.php
RewriteRule . index.php

/backend/config/main.php

$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'
);

return [
    'id' => 'app-backend',
    'basePath' => dirname(__DIR__),
    'controllerNamespace' => 'backend\controllers',
    'bootstrap' => ['log'],
    'homeUrl' => '/administrator',
    'modules' => [],
    'components' => [
        'request' => [
            'csrfParam' => '_csrf-backend',
            'baseUrl' => '/administrator',
        ],
        'user' => [
            'identityClass' => 'common\models\User',
            'enableAutoLogin' => true,
            'identityCookie' => ['name' => '_identity-backend', 'httpOnly' => true],
        ],
        'session' => [
            // this is the name of the session cookie used for login on the backend
            'name' => 'advanced-backend',
        ],
        'log' => [
            'traceLevel' => YII_DEBUG ? 3 : 0,
            'targets' => [
                [
                    'class' => 'yii\log\FileTarget',
                    'levels' => ['error', 'warning'],
                ],
            ],
        ],
        'errorHandler' => [
            'errorAction' => 'site/error',
        ],
// main - used to generate and parse URLs to backend from backend app
        'urlManager' => [
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            'baseUrl' => '/backend/web',
        ],
// slave - used to generate URLs to frontend from backend app
        'urlManagerFrontend' => [
            'class' => 'yii\web\urlManager',
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            'baseUrl' => '/',
            'rules' => [
                '/' => 'site/index',
                'home' => 'site/home',
                'about' => 'site/about',
                'moje-prace' => 'site/moje-prace',
                'umow-wizyte' => 'rezerwacje/create',
                'contact' => 'site/contact',
                'login' => 'site/login',
                'signup' => 'site/signup',
            ],
    ],
    'params' => $params,
];

/backend/controllers/SiteController.php

namespace backend\controllers;

use Yii;
use yii\web\Controller;
use yii\filters\VerbFilter;
use yii\filters\AccessControl;
use common\models\LoginForm;

/**
 * Site controller
 */
class SiteController extends Controller
{
    /**
     * {@inheritdoc}
     */
    public function behaviors()
    {
        return [
            'access' => [
                'class' => AccessControl::className(),
                'rules' => [
                    [
                        'actions' => ['login', 'error'],
                        'allow' => true,
                    ],
                    [
                        'actions' => ['logout', 'index'],
                        'allow' => true,
                        'roles' => ['@'],
                    ],
                ],
            ],
            'verbs' => [
                'class' => VerbFilter::className(),
                'actions' => [
                    'logout' => ['post'],
                ],
            ],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function actions()
    {
        return [
            'error' => [
                'class' => 'yii\web\ErrorAction',
            ],
        ];
    }

    /**
     * Displays homepage.
     *
     * @return string
     */
    public function actionIndex()
    {
        return $this->render('index');
    }

    /**
     * Login action.
     *
     * @return string
     */
    public function actionLogin()
    {
        if (!Yii::$app->user->isGuest) {
            return $this->goHome();
        }

        $model = new LoginForm();
        if ($model->load(Yii::$app->request->post()) && $model->login()) {
            return $this->goBack();
        } else {
            $model->password = '';

            return $this->render('login', [
                'model' => $model,
            ]);
        }
    }

    /**
     * Logout action.
     *
     * @return string
     */
    public function actionLogout()
    {
        Yii::$app->user->logout();

        return $this->goHome();
    }
}

VHOST & APACHE.CONF


apache2.conf

<Directory />
        Options FollowSymLinks
        AllowOverride All
        Require all granted
</Directory>

<Directory /usr/share>
        AllowOverride All
        Require all granted
</Directory>

<Directory /home/user/project>
        Options FollowSymLinks
        AllowOverride All
        Require all granted
</Directory>

vhost

<VirtualHost *:80>
    ServerAdmin admin@prst.app
    ServerName pp.test
    DocumentRoot /home/user/project/pp/

<Directory "/home/user/project/pp/">
    Options FollowSymLinks
        AllowOverride All
        Require all granted
</Directory>

    ErrorLog ${APACHE_LOG_DIR}/pp__error.log
    CustomLog ${APACHE_LOG_DIR}/pp_access.log combined

</VirtualHost>

I can not create the hyperlink in a view or redirect in controller from frontend to backend, and from backend to frontend.

Kamil Lonowski
  • 103
  • 2
  • 3
  • 11
  • In examples you've linked there are always two URL managers (separate for backend and fronted). Why you're using only one? – rob006 May 30 '18 at 12:19
  • sorry too much code i cut off. fixed. thank you ! – Kamil Lonowski May 30 '18 at 14:37
  • do i need this urlManager in common/main ? – Kamil Lonowski May 30 '18 at 14:42
  • you need to add the urlmanager configurations in `frontend/config/main.php` and `backend/config/main.php` separately rather than adding in the `common/config/main.php` – Muhammad Omer Aslam May 30 '18 at 15:52
  • @MuhammadOmerAslam fixed. Still not working after done steps below. – Kamil Lonowski May 30 '18 at 16:07
  • I am not sure how you followed the below answer, it **should** work correctly if you have followed and added correct `urlManager` configurations, can you update your question with the latest changes you have made ? – Muhammad Omer Aslam May 30 '18 at 16:13
  • @MuhammadOmerAslam updated. – Kamil Lonowski May 30 '18 at 21:25
  • ok a few things i need to ask, you are not using virtual hosts atall and you are using the url like `http://localhost/my-app` ? and you want your app to work in a way if someone types in `http://localhost/my-app` he should be automatically redirected to `http://localhost/my-app/frontend/web` and if type in `http://localhost/my-app/admin` it should redirect to `http://localhost/my-app/backend/web` and you want to be able to create links to the `frontend` via `backend` and to `backend` via `frontend` ? is it correct ? – Muhammad Omer Aslam May 30 '18 at 21:40
  • I'm using virtual hosts with different path than var/www/html, so i'm not strictly use http://localhost/my-app but instead of this i'm using http://site.test/ and this should be redirected to frontend, but i other side http://site.test/admin should be redirected to the backend, that's all i need to do, i thought it shouldn't be hard to do with framework... – Kamil Lonowski May 30 '18 at 21:52
  • if you are using virtual host then can you add the configuration, as per docs you already map the `frontend/web` directory to `site.test` and htaccess for the root directory is out of the context as when you type `site.test` you are in `frontend/web` directory so technically if you donot want to map another virtual host then you should modify the `.htaccess` inside of `frontend/web` directory, can you please add your virtual host configurations. – Muhammad Omer Aslam May 30 '18 at 23:00
  • ummm into the question please , it isnt readable here – Muhammad Omer Aslam May 30 '18 at 23:07
  • forgot about it. added. – Kamil Lonowski May 30 '18 at 23:14

2 Answers2

0

I'm assuming that your frontend is at http://localhosts and your backend at http://localhosts/admin. If your rewrite rules does not work correctly, you may try use symlinks for this - at least for me it was always simpler and less problematic way of handling frontend/backend URLs on shared hosting.


You always have 2 UrlManager components: main (for current environment) and slave (for second environment, for example for backend in frontend app). So in frontend/config/main.php you will have something like:

// ...
// main - used to generate and parse URLs to frontend from frontend app
'urlManager' => [
    'enablePrettyUrl' => true,
    'showScriptName' => false,
    'baseUrl' => '/',
    'rules' => [
        '/' => 'site/index',
        'home' => 'site/home',
        'about' => 'site/about',
        'moje-prace' => 'site/moje-prace',
        'umow-wizyte' => 'rezerwacje/create',
        'contact' => 'site/contact',
        'login' => 'site/login',
        'signup' => 'site/signup',
    ],
],
// slave - used to generate URLs to backend from frontend app
'urlManagerBackend' => [
    'class' => 'yii\web\urlManager',
    'baseUrl' => '/admin',
    'enablePrettyUrl' => true,
    'showScriptName' => false,
],
// ...

And in backend/config/main.php:

// ...
// main - used to generate and parse URLs to backend from backend app
'urlManager' => [
    'enablePrettyUrl' => true,
    'showScriptName' => false,
    'baseUrl' => '/admin',
],
// slave - used to generate URLs to frontend from backend app
'urlManagerFrontend' => [
    'class' => 'yii\web\urlManager',
    'enablePrettyUrl' => true,
    'showScriptName' => false,
    'baseUrl' => '/',
    'rules' => [
        '/' => 'site/index',
        'home' => 'site/home',
        'about' => 'site/about',
        'moje-prace' => 'site/moje-prace',
        'umow-wizyte' => 'rezerwacje/create',
        'contact' => 'site/contact',
        'login' => 'site/login',
        'signup' => 'site/signup',
    ],
],
// ...

As you can see, they're swapped - main UrlManager from frontend app is slave in backend app. Depending on current and target environment, you're using different URL manager.

If you want to generate URL to frontend from backend app:

Yii::$app->urlManagerFrontend->createUrl('site/index');
// result: http://localhost

If you want to generate URL to backend from backend app:

Yii::$app->urlManager->createUrl('site/index');
// result: http://localhost/admin/site/index

If you want to generate URL to backend from frontend app:

Yii::$app->urlManagerBackend->createUrl('site/index');
// result: http://localhost/admin/site/index

If you want to generate URL to frontend from frontend app:

Yii::$app->urlManager->createUrl('site/index');
// result: http://localhost
rob006
  • 21,383
  • 5
  • 53
  • 74
  • that's not working with my code above. i think the problem is with .htaccess file configuration and components in **main** files. They not co-operate... – Kamil Lonowski May 30 '18 at 16:18
  • I've never used `.htaccess` for such task, so I can't help with that. But you should be more specific - "not working" does not say anything useful. – rob006 May 30 '18 at 16:27
  • @r to be more specific, i can not send request to any other site (in frontend & backend) as site/index or site/login even when definetly "switch off" .htaccess by changing of the file name (filename). – Kamil Lonowski May 30 '18 at 16:38
  • Did you tried to remove only **root** `.htaccess` (leave `backend/web/.htaccess` and `frontend/web/.htaccess` untouched) and change `baseUrl` of frontend URL managers to `/frontend/web` and `baseUrl` of backend URL managers to `/backend/web`? Does URL `http://localhost/backend/web/site/index` works then? – rob006 May 30 '18 at 16:44
  • yes and i get it : Not Found The requested URL /backend/index.php was not found on this server. Apache/2.4.7 (Ubuntu) Server at pp.test Port 80 – Kamil Lonowski May 30 '18 at 21:14
  • Links are fully unconnected. nothing works. i just paste your code on a fresh yii2 advanced without .htaccess files and i get 404 error – Kamil Lonowski May 30 '18 at 21:18
  • I discover that it works with pretty urls disabled (false), is there any chance to set up pretty url ? – Kamil Lonowski May 30 '18 at 21:41
  • Wait, your `htaccess` is in `backend/web/.htaccess` or `backend/.htaccess`? How does this working URL looks like after disabling pretty URLs? – rob006 May 31 '18 at 06:42
  • backend/.htaccess – Kamil Lonowski May 31 '18 at 06:56
  • Well, it should be in `backend/web/.htaccess` - move it ant try https://stackoverflow.com/questions/50600193/yii2-frontend-to-backend-and-backend-to-frontend-controller-config-files-ht/50608905?noredirect=1#comment88229221_50608905 – rob006 May 31 '18 at 06:58
  • i'm so close to done that and mark this topic as solved. In few minutes i update the code. trying now set up the pretty url and post fully question. – Kamil Lonowski May 31 '18 at 06:59
  • added new answer with a short decription. – Kamil Lonowski May 31 '18 at 08:02
0

Finally it's done ! On the fresh yii2 advanced i set up connections between frontend and backend, but still have a problem with pretty url in both "sides".

backend/.htaccess


RewriteEngine on

#if directory or a file exist, use the request directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

#otherwise, forward to index.php
RewriteRule . index.php

backend/config/main.php


use \yii\web\Request;
$baseUrl = str_replace('/backend/web', '/backend/web', (new Request)->getBaseUrl());
$frontEndBaseUrl = str_replace('/backend/web', '/frontend/web', (new Request)->getBaseUrl());

$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'
);

return [
    'id' => 'app-backend',
    'basePath' => dirname(__DIR__),
    'controllerNamespace' => 'backend\controllers',
    'bootstrap' => ['log'],
    'modules' => [],
    'components' => [
        'request' => [
            'csrfParam' => '_csrf-backend',
        ],

'user' => [
            'identityClass' => 'common\models\User',
            'enableAutoLogin' => true,
            'identityCookie' => ['name' => '_identity-backend', 'httpOnly' => true],
        ],

        'session' => [
            // this is the name of the session cookie used for login on the backend
            'name' => 'advanced-backend',
        ],
        'log' => [
            'traceLevel' => YII_DEBUG ? 3 : 0,
            'targets' => [
                [
                    'class' => 'yii\log\FileTarget',
                    'levels' => ['error', 'warning'],
                ],
            ],
        ],
        'errorHandler' => [
            'errorAction' => 'site/error',
        ],


// main - used to generate and parse URLs to backend from backend app
        'urlManager' => [
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            'baseUrl' => '/backend/web',
        ],
// slave - used to generate URLs to frontend from backend app
        'urlManagerFrontend' => [
            'class' => 'yii\web\urlManager',
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            'baseUrl' => '/',
            'rules' => [
                '/' => 'site/index',
                'home' => 'site/home',
                'about' => 'site/about',
                'moje-prace' => 'site/moje-prace',
                'umow-wizyte' => 'rezerwacje/create',
                'contact' => 'site/contact',
                'login' => 'site/login',
                'signup' => 'site/signup',
            ],
        ],
    ],
    'params' => $params,
];

backend links for frontend

simply created with:

$frontendUrl= Yii::$app->urlManagerFrontend->createUrl('//');
echo yii\helpers\Html::a('link to frontend', $frontendUrl);



frontend/.htaccess


RewriteEngine on

#if directory or a file exist, use the request directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

#otherwise, forward to index.php
RewriteRule . index.php

frontend/config/main.php


use \yii\web\Request;
$baseUrl = str_replace('/frontend/web', '/frontend/web', (new Request)->getBaseUrl());
$backEndBaseUrl = str_replace('/frontend/web', '/backend/web', (new Request)->getBaseUrl());


$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'
);

return [
    'id' => 'app-frontend',
    'basePath' => dirname(__DIR__),
    'bootstrap' => ['log'],
    'controllerNamespace' => 'frontend\controllers',
    'components' => [
        'request' => [
            'csrfParam' => '_csrf-frontend',
        ],
        'user' => [
            'identityClass' => 'common\models\User',
            'enableAutoLogin' => true,
            'identityCookie' => ['name' => '_identity-frontend', 'httpOnly' => true],
        ],
        'session' => [
            // this is the name of the session cookie used for login on the frontend
            'name' => 'advanced-frontend',
        ],
        'log' => [
            'traceLevel' => YII_DEBUG ? 3 : 0,
            'targets' => [
                [
                    'class' => 'yii\log\FileTarget',
                    'levels' => ['error', 'warning'],
                ],
            ],
        ],
        'errorHandler' => [
            'errorAction' => 'site/error',
        ],

// main - used to generate and parse URLs to frontend from frontend app
        'urlManager' => [
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            'baseUrl' => $baseUrl,
            'rules' => [
                '/' => 'site/index',
                '/home' => 'site/home',
                '/about' => 'site/about',
                'moje-prace' => 'site/moje-prace',
                'umow-wizyte' => 'rezerwacje/create',
                'contact' => 'site/contact',
                'login' => 'site/login',
                'signup' => '/site/signup',
            ],
        ],
// slave - used to generate URLs to backend from frontend app
        'urlManagerBackend' => [
            'class' => 'yii\web\urlManager',
            'baseUrl' => $backEndBaseUrl,
            'enablePrettyUrl' => false,
            'showScriptName' => false,
        ],

    ],
    'params' => $params,
];

frontend links for backend

simply created with:

$backendUrl= Yii::$app->urlManagerBackend->createUrl('//');
echo yii\helpers\Html::a('link to backend', $backendUrl);

In the root directory what means http://localhost/app-name/ i created index.php file for redirecting to frontend while clicking link on backend (to frontend):

/index.php


header("Location: http://pp.test/frontend/web/", true, 301);
exit();

And by now it works so so, but i'm not able to enable pretty url in the backend as it does not works corectlly. And also i do not think that's a good way using redirecting from other file especially from root directory.

Please note, that in common/config/main.php no changes is needed and do not need .htaccess file in the root directory.

Kamil Lonowski
  • 103
  • 2
  • 3
  • 11