Module routing do not work when using urlManager rules

I have created rbac module with Gii inside my basic template.

When I visit


it works.

But then I wanted to use urlManager rule that I saw in Yii2 cookbook that will make site controller disappear from the url.

So my new urlManager configuration looks like this

        'urlManager' => [

            'enablePrettyUrl' => true,

            'showScriptName' => false,

            'rules' => [

                '<alias:\w+>' => 'site/<alias>',



But now, http://localhost/yii2-basic/web/rbac ends in 404.

What can I do ?

You can instruct your webserver to point the webroot at the ‘web’ folder - as explained in the docs.

I can not change apache config on production. I have tried this guide:

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

But it is not working.

If I remove:

'rules' => [

    '<alias:\w+>' => 'site/<alias>',


it works. But I want to use these rules.