如何使用 .htaccess 将任何 .css 文件重定向到我服务器上的页面/ Controller ?
我目前有以下规则:
# Remove index.php from Codeigniter
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
我现在想要将任何 .css 文件重定向到例如 http://127.0.0.1/asset/css?file=stylesheet.css .我尝试了以下但收到 404。
RewriteRule .*\.(css)$ /asset/css?file=$0 [NC,L]
最佳答案
#Rule for css
RewriteRule ([^.]+)\.css$ asset/css?file=$1.css [NC,L]
#end of css rule
# Remove index.php from Codeigniter
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
关于css - .htaccess mod_rewrite 将所有 css 重定向到页面/ Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34040105/