Good day. I am developing a small application on Yii 2 (using the basic template). Faced with the fact that the css-file that I want to use for the design of the module and which is located in the structure of the module is not connected. Here is the order of my actions:
- Created a template file for the / modules/ admin/views/layouts/main.php module
- In the file / modules/admin/Module.php in the init () method indicated that I would use this template for the module.
- In the module folder, created the css folder and in it the /modules/admin/css/admin_style.css file
- In the module folder I created the assets folder and in it the file /modules/admin/assets/AdminAsset.php , in which I indicated that I want to connect /modules/admin/css/admin_style.css
In the template file I indicated that I will use AdminAsset:
use app \ modules \ admin \ assets \ AdminAsset;
AdminAsset :: register ($ this);
In the developer’s panel I see that my css-file is registered, but cannot connect (status 404):
I suspect that the reason is that the folder with css-files is not public and you need to allow access to it .htaccess . In my application I use 2 .htaccess files : in the / web folder and in the root. In the / web folder this:
RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . index.php And at the root - here is this:
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 Please help me figure it out, otherwise I’m not strong in the .htaccess directives.
PS There is also a desire to upload files using the / uploads folder, not / web / uploads , but this, in my opinion, is a question from the same plane

admin_style.cssat what address is trying to load? from site.com/assets/xxxx/admin_style.css ? - pa3py6akaAdminAsset.phpcode, I think there is a mistake - pa3py6akapublic $sourcePath = '@app/modules/admin';public $css = ['css/module_admin.css','css/new.css',];But I had to manually delete the cache from the web / assets /. How to make it not created there in DEV mode? - Vlad