how to to rewrite all .css file to a controller in yii2

Hi all,

I am newbie. I am trying to rewrite all .css file to a PHP file by using .htaccess:

I want to when I call http://yii2web/admin/css/site.css it will rewrite to http://yii2web/admin/index.php/optioncss

Here are my .htaccess:




<IfModule mod_rewrite.c>

    RewriteCond %{REQUEST_URI} ^/(admin)

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

    RewriteRule ^admin/css/(.*)$ admin/index.php/optioncss [L]


    RewriteCond %{REQUEST_URI} !^/backend/web/(assets|css)/

    RewriteCond %{REQUEST_URI} ^/(admin)

    RewriteRule ^.*$ backend/web/index.php [L]




    RewriteCond %{REQUEST_URI} ^/(assets|css)

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

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


    RewriteCond %{REQUEST_URI} !^/(frontend|backend)/web/(assets|css)/

    RewriteCond %{REQUEST_URI} !index.php

    RewriteCond %{REQUEST_FILENAME} !-f [OR]

    RewriteCond %{REQUEST_FILENAME} !-d

    RewriteRule ^.*$ frontend/web/index.php [L]

</IfModule>



but it does not work for me. Please help, Thanks!