Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2006-02-03 21:02:03
- Andrew
- Plugin Author
- Registered: 2004-02-23
- Posts: 730
[howto] How to rewrite /textpattern/css.php to /css/layout.css (or whatever)
So for whatever reason, you don’t want the /textpattern/css.php?s=foo
or /textpattern/css.php?n=bar
in your <head>
, but you still want to keep your css within the Textpattern db/admin. This technique is nothing groundbreaking, but it can come in handy.
I sometimes find it useful to use dated versions of stylesheets; I’m not a fan of using the ?s=section
conditional css, relying more on body IDs and the power of css itself. Here are a few rewrite rules that I use:
RewriteRule ^css/(.*)\.css$ /textpattern/css.php?n=$1 [NC,L]
- Takes whatever the filename is and uses it as the “n” value for css.php
- For instance, “layout.css”
->
“css.php?n=layout”
RewriteRule ^css/layout\.css$ /textpattern/css.php [QSA,NC,L]
- carries full querystring to css.php
- /css/layout.css?s=section OR /css/layout.css?n=foo
RewriteRule ^css/layout\.css$ /textpattern/css.php?n=%{QUERY_STRING} [NC,L]
- this is what I use for dated versioning of stylesheets
/css/layout.css?20050203
=>css.php?n=20050203
- modify to
?s=
to use w/ section-specific css
- There are probably some more clever ways of implementing, but I’ll stop here… you get the picture ; )
Last edited by Andrew (2006-03-01 20:43:57)
Offline
#2 2006-02-03 21:06:47
- Andrew
- Plugin Author
- Registered: 2004-02-23
- Posts: 730
Re: [howto] How to rewrite /textpattern/css.php to /css/layout.css (or whatever)
A few definitions:
- QSA = [Q]uery[S]tring [A]ttached
- NC = [N]ot [C]ase sensitive
- L = [L]ast rule of this set
Offline
Re: [howto] How to rewrite /textpattern/css.php to /css/layout.css (or whatever)
Andrew what do you mean by dated stylesheets? If it’s what I’m thinking you can expire styles with this method??
Offline
#4 2006-02-04 16:08:51
- Andrew
- Plugin Author
- Registered: 2004-02-23
- Posts: 730
Re: [howto] How to rewrite /textpattern/css.php to /css/layout.css (or whatever)
Honestly, there may/may not be anything useful here. I figured the question about css.php might be asked at some point in time and that I might as well make a note of how to do it. I use this method for two reasons: 1) to track versions of stylesheets in case I break something I can roll back/forward (if the stylesheet isn’t a hard file, there no way to use versioning unless you do this), and 2) if I’m trying to totally hide the technology powering a website to the outside world.
Offline
#5 2006-02-13 12:39:42
- SteveC
- New Member
- Registered: 2004-11-06
- Posts: 9
Re: [howto] How to rewrite /textpattern/css.php to /css/layout.css (or whatever)
soulship wrote:
Andrew what do you mean by dated stylesheets? If it’s what I’m thinking you can expire styles with this method??
I find this really useful for when you’re updating stuff regulary, browsers tend not to cache it.
Offline