.htaccess url在Yii2中重写

时间:2015-01-27 07:46:42

标签: .htaccess url rewrite yii2

我是新手。我试图使用.htaccess:

将所有.css文件重写为PHP文件

我想在致电http://yii2web/admin/css/site.css时,它会重写为http://yii2web/admin/index.php/optioncss

这是我的.htaccess:

<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_URI} ^/(admin)
RewriteRule ^admin/assets/(.*)$ backend/web/assets/$1 [L]

将所有.css文件重写为控制器optioncss

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]

但它对我不起作用。请帮忙,谢谢!

0 个答案:

没有答案