I use Yii2 Adnvanced. Posted by .htaccess

Options +FollowSymLinks IndexIgnore */* RewriteEngine on # Если запрос начинается с /admin, то заменяем на /backend/web/ RewriteCond %{REQUEST_URI} ^/admin RewriteRule ^admin\/?(.*) /backend/web/$1 # Добавляем другой запрос /frontend/web/$1 RewriteCond %{REQUEST_URI} !^/(frontend/web|backend/web|admin) RewriteRule (.*) /frontend/web/$1 # Если frontend запрос RewriteCond %{REQUEST_URI} ^/frontend/web RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /frontend/web/index.php # Если backend запрос RewriteCond %{REQUEST_URI} ^/backend/web RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /backend/web/index.php 

The website at http://site.ru is loading well, but the admin at http://site.ru/admin first loads the admin code, and below is the main website. I noticed that if you remove

 <?php $this->beginBody() ?> <?php $this->endBody() ?> 

the error disappears. Help, I do not know where to look

    1 answer 1

    At the root of the site such .htaccess :

     Options -Indexes IndexIgnore */* Options FollowSymlinks RewriteEngine on RewriteRule ^admin$ backend/web/ [L] RewriteCond %{REQUEST_URI} ^/(admin) RewriteRule ^admin(\/?.*)$ backend/web/$1 [L] RewriteCond %{REQUEST_URI} ^/ RewriteRule ^(\/?.*)$ frontend/web/$1 [L] 

    In frontend/web and backend/web :

     Order Allow,Deny Allow from all AddDefaultCharset utf-8 RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . index.php 
    • also, in / admin loads also the frontend - Diefair
    • Very interesting. Can a frontend view be connected somewhere in the template? - pa3py6aka
    • checked, did not find - Diefair