Answer the question
In order to leave comments, you need to log in
How to make routing in yii2advenced? How to include files from asset?
Good day everyone, I'm trying to figure out routes in yii2 advenced. I don't have much experience, so I apologize in advance. Questions elementary for knowledgeable people.
It costs OpenServer in which Apache 2.2 + Nginx 1.8
I use the advanced template, since the administrative part is needed.
The backend folder and all references to the backend have been renamed to admin
The site is opened by site.local site.local/site/about
Admin panel by site.local/admin/site/login
But css and js files from asset are not connected
Root htaccess settings
RewriteEngine On
# rewrite for the frontend - основной редирект в frontend/web
RewriteCond %{REQUEST_URI} !^/(admin/web|admin)
RewriteRule !^frontend/web /frontend/web%{REQUEST_URI} [L]
# rewrite for the backend - все что начинается с /admin редиректится в /backend/web
RewriteCond %{REQUEST_URI} ^/admin
RewriteRule ^admin(.*) /admin/web/$1 [L]
# if under frontend/web file or directory exists - take it - если в frontend/web папка или файл существуют - берем их
RewriteCond %{REQUEST_URI} ^/frontend/web
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward to index.php - все остальное отправляется на index.php во фронтенде (все что начинается с frontend/web)
RewriteRule . /frontend/web/index.php [L]
# same for backend - то же самое, но для бэкенда
RewriteCond %{REQUEST_URI} ^/admin/web
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /admin/web/index.php [L]
RewriteEngine On RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
'homeUrl' => '',
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
],
'request' => [
'baseUrl' => '',
],
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question