0

I'm using Yii2 advanced template. Where I want to hide 'backend/web/index.php' & 'frontend/web/index.php' too. I'm able to achieve this with following code -

.htaccess at root -

Options -Indexes
RewriteEngine on

<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_URI} !^/backend/web/(assets|css)/
RewriteCond %{REQUEST_URI} admin
RewriteRule .* backend/web/index.php [L]

RewriteCond %{REQUEST_URI} !^/(frontend|backend)/web/(assets|css)/
RewriteCond %{REQUEST_URI} !admin
RewriteRule .* frontend/web/index.php [L]
</IfModule>

.htaccess at frontend & backend's web -

RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . index.php

frontend config -

'request'=>[
            'class' => 'common\components\Request',
            'web'=> '/frontend/web'
        ],
'urlManager' => [
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            'rules' => [
            ],
        ],

backend config -

'request'=>[
            'class' => 'common\components\Request',
            'web'=> '/backend/web',
            'adminUrl' => '/admin'
        ],
'urlManager' => [
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            'rules' => [
            ],
        ],

BUT, the problem with this is it doesn't load any css (asset). The pages are displaying only text & html Like this - pages without css

I also tried to modify request component as -

'request'=>[
                'class' => 'common\components\Request',
                'web'=> '/frontend/web/assets'
            ],

then css works, But pretty url doesn't work. All the frontend/web/... or backend/web/... displayed then. unwanted url part Please let me know where I'm going wrong. And tell me what should I do to keep URL pretty with proper assets.

Tushar Walzade
  • 3,737
  • 4
  • 33
  • 56

0 Answers0