Why is cyclic 302 redirect?

Hello. Configure Apache for a project on Yii2. Work locally via OpenServer. If I'm in settings OpenServer prescribe the root directory, all works well.
Clean settings and try to set up redirection using .htaccess
The Yii2 advanced template. For first you need to configure routing on the frontend/web and then to the backend/web
Here are the files .htaccess I've got:
The root of the project:
<IfModule mod_rewrite.c>
 Options +FollowSymlinks
 RewriteEngine On

<IfModule mod_rewrite.c>
 RewriteCond %{REQUEST_URI} ^/.*
 RewriteRule ^(.*)$ /frontend/web/$1 [L]

Directory frontend/web:
# use mod_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
# use index.php as index file
DirectoryIndex index.php

As a result, when you try to go for example on the main redirects to happen:

Can you please tell me what my error is?
Thanks in advance to all responded.
March 20th 20 at 11:35
1 answer
March 20th 20 at 11:37
Settings .htaccess was correct. The error was in the configuration of Yii. You need to write for the frontend
'request' => [
 'baseUrl' => "

For backend
'request' => [
 'baseUrl' => '/backend'

Find more questions by tags Yiihtaccess