im-richard / Scaffold

Extend, combine and compress CSS
http://github.com/IAMRichardT/Scaffold/wiki
161 stars 19 forks source link

How I use Scaffold with a .htaccess #5

Closed balupton closed 14 years ago

balupton commented 14 years ago

In our CMS we are using Scaffold (well the old version). Originally we passed the CSS files via the urls as indicated in the Wiki by doing: <link rel='stylesheet' href='/scaffold/parse.php?file=/path/to/file.css />

In the older version we always had issues with Scaffold stuffing up url() CSS properties, so rather than rewriting we came up with the following .htaccess

<IfModule mod_rewrite.c> 
    RewriteEngine   on
    RewriteCond     %{REQUEST_FILENAME}     -f
    RewriteCond     %{REQUEST_URI}          \.css$
    RewriteCond     %{QUERY_STRING}         csscaffold
    RewriteRule     ^(.+)$                  styles/csscaffold.php?f=%{REQUEST_URI}&%{QUERY_STRING}
</IfModule>

This way we can still reference our CSS normally without touching our HTML files at all. <link rel='stylesheet' href='/path/to/file.css /> All the old CSS that doesn't use Scaffold works perfectly. And we can include a new scaffold CSS file by using: @import url("./csscaffold.css?csscaffold");

anthonyshort commented 14 years ago

Nice! I'm going to put this in the wiki :)