Problem with Yii2 pretty urls

I’ve been trying all day to get pretty urls working in the advanced app framework for Yii2

I have in my root .htaccess

Options -Indexes

RewriteEngine on

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

#if the request is not to the backend, route it to /frontend/web

RewriteCond %{REQUEST_URI} !^/backend

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

#otherwise route the request to the backend

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

I have in my /frontend /backend web folders.

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

I have enabled pretty url in /common/config/main.php

'urlManager' => [

       'class' => 'yii\web\UrlManager',

       // Disable index.php

       'showScriptName' => false,

       // Disable r= routes

       'enablePrettyUrl' => true,

       'baseUrl' =>'',

       'rules' => array(


           '<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',

           '<controller:\w+>/<action:\w+>' => '<controller>/<action>',



I get Forbidden in root (it should route to /web/frontend unless I put /backend in the path)

and if I go to


The page displays. But all links return Not found 404 errors.

If I switch

‘showScriptName’ => false,


‘showScriptName’ => true,

urls work but have /index.php/ in the paths.

So first problem is that the hta redirect to /frontend/web is simply not firing at all. mod_rewrite is enabled in apache. And if I put a deny all in any of these files, it works.

Secondly /index.php is not proessed by

RewriteRule . index.php or

RewriteRule ^(.)\?$ index.php?r=$1 [L,QSA]

Or any other version of this command I try.

I have a Yii 1.4 build running on another vhost on the same server with the exact same server and base config.

Its pretty url and hide index stuff works fine.

So what am I doing wrong????