V
V
Valeriu Vodnicear2017-01-05 05:04:03
Yii
Valeriu Vodnicear, 2017-01-05 05:04:03

Why files are not included in Yii2?

Hello,
I have a .htacces file at the root of the site:

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

and in the /web folder there is also a .htacces file:
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . index.php

I tried to create a CNC, and it turned out, only now styles, JS files are not connected.
Server: OpenServer
In config/web.php added: and more
'baseUrl' => ''
'urlManager' => [
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            'suffix' => '.html',
            'rules' => [
                [
                    'pattern' => '',
                    'route' => 'site/index',
                    'suffix' => ''
                ],
                '<action:(about|contact|login)>' => 'site/<action>',
//                '<action:about>' => 'page/about',

                    '<controller>/<action>' => '<controller>/<action>',
                    'site/hello/<name:\w+>' => 'site/hello',
            ],
        ],

Does anyone know a solution?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Valeriu Vodnicear, 2017-01-25
@vodnicear

The problem was in the server settings
And it was Apache-2.4-Nginx-1.7

M
Maxim Fedorov, 2017-01-05
@qonand

Replace .htaccess at the root with

Options +FollowSymLinks
IndexIgnore */*
RewriteEngine on

RewriteCond %{REQUEST_URI} ^/.*    
RewriteRule ^(.*)$ web/$1 [L]

RewriteCond %{REQUEST_URI} !^/web    
RewriteCond %{REQUEST_FILENAME} !-f [OR]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ web/index.php

D
Dmitry, 2017-01-05
@slo_nik

Goodnight.
Actually, resources (css, js, fonts) are connected via AssetBundle

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question