Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2005-11-19 18:51:36

beniji
New Member
Registered: 2005-11-19
Posts: 4

Generate clean URL for dynamic CSS?

Instead of the standard dynamic CSS urls output by Textpattern

href=”… textpattern/css.php?s=default”

I would like to have

href=”…textpattern/default.css”

And so on for each section.

This is because I am using texpattern on a PHP enabled server which is auto mirrored using wget to a non-PHP enabled server. If the href refers to a css extension, wget will download it with a .css extension so that apache can serve it properly and with the right content type.

Can this be done using mod_rewrite and a textpattern tag variable to access the “section” value?

Thanks,

Ben (txp newbie)

Offline

#2 2005-11-20 04:25:18

NXArmada
Member
From: Sevierville, TN
Registered: 2005-09-13
Posts: 82

Re: Generate clean URL for dynamic CSS?

One way you can do it is put your CSS into a file rather than running it through TXP.


Ryan

Offline

#3 2005-11-21 00:06:21

beniji
New Member
Registered: 2005-11-19
Posts: 4

Re: Generate clean URL for dynamic CSS?

Yeah I could do that but I’m a perfectionist.

I worked out how to do it:

1) In the page template replace href=“txp:css /” with: href=“txp:site_url /textpattern/txp:section /.css”

2) In .htaccess add a rewrite rule: RewriteRule (.)/(.)\.css$ $1/css.php?s=$2

Thus the ugly relative URL “textpattern/css.php?s=default” becomes “textpattern/default.css”.

This might be useful for anyone else who does not want to sacrifice dynamic editing of CSS but also wants to take a static mirror snapshot of their site – the snapshot CSS file will then be served with the right content type.

Last edited by beniji (2005-11-21 00:10:57)

Offline

Board footer

Powered by FluxBB