Answer the question
In order to leave comments, you need to log in
How to set up apache 2 Yii ubuntu?
at var/www/ created diary.lc/ at /etc/apache2/sites-available/ created diary.lc.conf with the following parameters
<VirtualHost *:80>
ServerName diary.lc
ServerAlias www.diary.lc
DocumentRoot /var/www/diary.lc
<Directory /var/www/diary.lc/>
Options Indexes FollowSymlinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
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_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
'urlManager' => [
'class' => 'yii\web\UrlManager',
'enablePrettyUrl' => true,
'showScriptName' => false,
'rules' => [
'index' =>'frontend/web/index',
'<action>'=> 'site/<action>',
]
],
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