Answer the question
In order to leave comments, you need to log in
Why is there an error when using urlManager?
I use the advanced template, but for some reason, if I connect urlManager, then 1 stops working, or rather, not even the urlManager itself, but showScriptName => false
, and in general, some styles are completely disabled, I connect like this
'urlManager' => [
'class' => 'yii\web\UrlManager',
'enablePrettyUrl' => true,
/*'showScriptName' => false,*/
],
Options +FollowSymLinks
IndexIgnore */*
RewriteEngine on
# Если запрос начинается с /admin, то заменяем на /backend/web/
RewriteCond %{REQUEST_URI} ^/admin
RewriteRule ^admin\/?(.*) /backend/web/$1
# Если запрос начинается с /api, то заменяем на /rest/web/
RewriteCond %{REQUEST_URI} ^/api
RewriteRule ^api\/?(.*) /rest/web/$1
# Добавляем другой запрос /frontend/web/$1
RewriteCond %{REQUEST_URI} !^/(frontend/web|backend/web|rest/web|admin|api)
RewriteRule (.*) /frontend/web/$1
# Если frontend запрос
RewriteCond %{REQUEST_URI} ^/frontend/web
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /frontend/web/index.php
# Если api запрос
RewriteCond %{REQUEST_URI} ^/rest/web
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /rest/web/index.php
# Если backend запрос
RewriteCond %{REQUEST_URI} ^/backend/web
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /backend/web/index.php
Answer the question
In order to leave comments, you need to log in
It's in .htacces
Options +FollowSymLinks
IndexIgnore */*
RewriteEngine on
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward it to index.php
RewriteRule . index.php
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'rules' => [
'/' => 'site/index'
/* другие правила */
],
],
Can you elaborate on what kind of error you have, how you set the routing, that is, the rules, and how to understand the styles are disabled, that is, you have some css files that stop loading when you click on some link. In general, the urlManager component is connected like this
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'rules' => [
'название ссылки' => 'имя контроллера/имя экшена'
]
]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question