Yii2 humanly understandable URLs

Good morning!)

The urls does not work correctly. I have a clean yii2 template. I uncommented in config/web.php this block:


'urlManager' => [

            'enablePrettyUrl' => true,

            'showScriptName' => false,

            'rules' => [

            ],

        ],

Added ‘baseUrl’=> ‘’ in requests in components,

Add in the root folder .htaccess:


Options +FollowSymLinks

IndexIgnore */*

RewriteEngine on


RewriteCond %{REQUEST_URI} !^/(web)

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

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

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

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

RewriteRule (.*) /web/$1


RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . /web/index.php

In the web folder added:


RewriteBase /


RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d


RewriteRule . index.php

Styles removed. When I delete ‘baseUrl’=> ‘’, they are returned. Link /site/about leads on the main page and not to the web/site/about. In the Source code the css plugged.


<link href="/assets/7fb759e5/css/bootstrap.css" rel="stylesheet">

<link href="/css/site.css" rel="stylesheet"></head>

Thank you! Good day))) :rolleyes:

You need remove web from RewriteRule and add it to path in your virtual host configuration.

Check https://github.com/yiisoft/yii2-app-advanced/blob/master/docs/guide/start-installation.md

Hi! Thank you! The problem wasn’t in URLs(i confused). When i updated version of my apach styles returned.