Answer the question
In order to leave comments, you need to log in
How to set up yii2 advanced on ubuntu?
On request in URl
server/mysite/frontendeverything starts up fine.
server/my_site/adminit doesn't flip.
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
# use mode rewrite for pretty URL support
RewriteEngine on
# 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
'homeUrl' => '/admin',
'id' => 'app-backend',
'basePath' => dirname(__DIR__),
'controllerNamespace' => 'backend\controllers',
'bootstrap' => ['log'],
'modules' => [],
'components' => [
'request' => [
'baseUrl' => '/admin',
'csrfParam' => '_csrf-backend',
],
Answer the question
In order to leave comments, you need to log in
Good evening.
RootDirectory set to the root of the site, not backend / web and not frontend / web
At the root of the site .htaccess
RewriteEngine On
RewriteRule ^(frontend|backend)/web/ - [L]
RewriteCond %{REQUEST_URI} ^/(admin)
RewriteRule ^admin(\/?.*)$ backend/web/$1 [L]
RewriteCond %{REQUEST_URI} ^/
RewriteRule ^(\/?.*)$ frontend/web/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
'baseUrl' => '/admin'
http://site.com
you will get to the frontend, and to the address http://site.com/admin
- to the admin panel. http://site.com/subsite
. RewriteEngine On
RewriteRule ^(frontend|backend)/web/ - [L]
RewriteCond %{REQUEST_URI} ^/(subsite/admin)
RewriteRule ^admin(/.*)?$ backend/web/$1 [L]
RewriteCond %{REQUEST_URI} ^/(subsite)
RewriteRule ^(.*)$ frontend/web/$1 [L]
$baseUrl = str_replace('/backend/web', '', (new yii\web\Request)->getBaseUrl());
'baseUrl' => $baseUrl . '/admin'
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question