Pretty CSS URLs (easycaching?) on 1.6.3 and lighttpd with a 4 lines patch
Posted: Wed Aug 12, 2009 8:56 pm
Hello all,
I'd like to share this tip on how to make pretty CSS URLs, not only regular page.html pretty URL.
It requires a tiny patch. Hence no support if you use it. See http://forum.cmsmadesimple.org/index.ph ... 132.0.html
And it has not been much tested. And it may break something. You have been warned : no support neither about this hack nor for your contaminated CMSms installs.
Background : I like pretty URLs very much because they are end user friendly and web ecosystem compliant (proxy, cache, replication...) Hopefully CMSms has a pretty URLs feature for pages. It still relies on /stylesheet.php?this=that to broadcast CSS to the web. I'm proposing to make CSS URLs pretty too.
config.php extract :
Nothing funky actually 
mod_rewrite extract :
It is a lighttpd quick and dirty example (1 line for .html and 1 line for .css) but it would be the same with Apache (htaccess).
The patch in plugins: diff 1.6.3-function.stylesheet.php new-function.stylesheet.php
Result : now the {stylesheet} plugin's output looks like this :
which is compatible with CSS /my/root/path/image(upload...)
Presumed issue : the "media" field is required. But it doesn't hurt the web to provide it.
Hope you like this hack.
If you want to talk about lighttpd please start another thread. This one is about pretty CSS URLs.
Have fun with CMSms.
Pierre M.
I'd like to share this tip on how to make pretty CSS URLs, not only regular page.html pretty URL.
It requires a tiny patch. Hence no support if you use it. See http://forum.cmsmadesimple.org/index.ph ... 132.0.html
And it has not been much tested. And it may break something. You have been warned : no support neither about this hack nor for your contaminated CMSms installs.
Background : I like pretty URLs very much because they are end user friendly and web ecosystem compliant (proxy, cache, replication...) Hopefully CMSms has a pretty URLs feature for pages. It still relies on /stylesheet.php?this=that to broadcast CSS to the web. I'm proposing to make CSS URLs pretty too.
config.php extract :
Code: Select all
$config['url_rewriting'] = 'mod_rewrite';
$config['page_extension'] = '.html';
$config['use_hierarchy'] = true;
$config['query_var'] = 'page';

mod_rewrite extract :
Code: Select all
server.modules = ( "mod_this", "mod_that", "mod_rewrite" )
var.mydir = "/my/root/path/"
url.rewrite = (
var.mydir + "(.+)\.html" => var.mydir + "index.php?page=$1",
var.mydir + "(.+)\-(.+)\.css" => var.mydir + "stylesheet.php?cssid=$2&mediatype=$1"
)
The patch in plugins: diff 1.6.3-function.stylesheet.php new-function.stylesheet.php
Code: Select all
29,30c29,30
< //if( $config['url_rewriting'] != 'none' )
< if( 0 )
---
> if( $config['url_rewriting'] == 'mod_rewrite' )
> //if( 0 )
32c32
< $url = $config['root_url'].'/stylesheet.php/'.$cssid;
---
> $url = $config['root_url'];
35c35
< $url .= '/'.$media;
---
> $url .= '/'.$media.'-';
36a37
> $url .= $cssid.'.css';
Code: Select all
<link rel="stylesheet" type="text/css" media="handheld" href="http://server.tld/my/root/path/handheld-41.css" />
Presumed issue : the "media" field is required. But it doesn't hurt the web to provide it.
Hope you like this hack.
If you want to talk about lighttpd please start another thread. This one is about pretty CSS URLs.
Have fun with CMSms.
Pierre M.