M
M
Michael2022-03-20 20:21:23
Yii
Michael, 2022-03-20 20:21:23

Why are css and js not included?

Hello everybody! I am using yii2 basic template. In general, there is a template, all the necessary js and css have been transferred, .htaccess is configured. When opening the page, the style files and libraries are not connected, in the console it gives an error that the path was not found. But if you remove the line 'baseUrl' => ''in the web.php file, then everything starts working. Having looked in previous projects, which I also wrote in yii, I have this line everywhere and there are no such problems.
.htaccess

Options +FollowSymLinks
IndexIgnore */*
RewriteEngine on

RewriteCond %{REQUEST_URI} !^/(web)
RewriteRule ^assets/(.*)$ /web/assets/$1 [L]
RewriteRule ^css/(.*)$ web/css/$1 [L]
RewriteRule ^fonts/(.*)$ web/fonts/$1 [L]
RewriteRule ^js/(.*)$ web/js/$1 [L]
RewriteRule ^img/(.*)$ web/img/$1 [L]
RewriteRule (.*) /web/$1
RewriteRule ^sitemap.xml$ /web/sitemap.xml$1 [L]
RewriteRule ^favicon.ico$ /web/favicon.ico [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /web/index.php

AppAsset.php
class AppAsset extends AssetBundle
{
    public $basePath = '@webroot';
    public $baseUrl = '@web';
    public $css = [
        'fonts/flaticon/flaticon.css',
        'css/animate.css',
        'css/font-awesome.css',
        'css/pe-icon-7-stroke.css',
        'css/owl.carousel.css',
        'css/chosen.css',
        'css/jquery.bxslider.css',
        'css/style.css',
        '//fonts.googleapis.com/css?family=Open+Sans:300,300i,400,400i,600,600i,700,700i,800,800i&display=swap',
    ];
    public $js = [
        'js/jquery-2.1.4.min.js',
        'js/jquery-ui.min.js',
        'js/owl.carousel.min.js',
        'js/wow.min.js',
        'js/jquery.actual.min.js',
        'js/chosen.jquery.min.js',
        'js/jquery.bxslider.min.js',
        'js/jquery.sticky.js',
        'js/jquery.elevateZoom.min.js',
        'js/fancybox/source/jquery.fancybox.pack.js',
        'js/fancybox/source/helpers/jquery.fancybox-media.js',
        'js/fancybox/source/helpers/jquery.fancybox-thumbs.js',
        'https://maps.googleapis.com/maps/api/js?key=AIzaSyC3nDHy1dARR-Pa_2jjPCjvsOR4bcILYsM',
        'js/function.js',
        'js/Modernizr.js',
        'js/jquery.plugin.js',
        'js/jquery.countdown.js',
    ];
    public $depends = [
        'yii\web\YiiAsset',
        'yii\bootstrap\BootstrapPluginAsset',
    ];
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question