.htaccess subdirectory route is not working

my htaccess configuration in the root directory looks like


<IfModule mod_rewrite.c>

Options +FollowSymlinks

RewriteEngine On

RewriteCond %{REQUEST_URI} ^/(assets|css|js|images|blog)

RewriteRule ^assets/(.*)$ frontend/web/assets/$1 [L]

RewriteRule ^css/(.*)$ frontend/web/css/$1 [L]

RewriteRule ^js/(.*)$ frontend/web/js/$1 [L]

RewriteRule ^images/(.*)$ frontend/web/images/$1 [L]

RewriteRule ^blog/(.*)$ frontend/web/blog/$1 [L]

RewriteRule ^(.*)$ frontend/web/$1 [L]


RewriteCond %{REQUEST_URI} !^/(frontend|backend)/web/(assets|css|js|blog)/

RewriteCond %{REQUEST_URI} !index.php

RewriteCond %{REQUEST_FILENAME} !-f [OR]

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^.*$ frontend/web/index.php

in frontend/web looks like


RewriteEngine on

RedirectMatch 404 /\.git

RedirectMatch 404 /composer\.

RedirectMatch 404 /.bowerrc


RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d


RewriteRule . index.php

everything works fine with images,css,js (for example, path site.com/images works correctly) except "/blog" page, after click on menu button, app redirects me to "site.com/frontend/web/blog" instead of "site.com/blog"

im using yii2 NavBar widget


$menuItems = [

  ...

       ['label' => 'Blog', 'url' => ['/blog/index'], 'options'=>['class'=>'font-menu']],

url manager rules


        'rules' => [

            'blog/<url>/<category_id>' => 'blog/one',

            'blog/<category_id>' => 'blog/category',

            'blog' => 'blog/index',

don`t understand how to fix it, please help :(

found a solution this way

in main-local config


   'request' => [

        'baseUrl' => '',

    ],

Glad you found it, and thanks for posting solution.