On Tue, Nov 09, 2004 at 02:30:16AM +1100, Howard Lowndes wrote:
> I have a CSS file which has to be named *.css so that Apache knows to
> send it as a text/css mime type but I want to do some PHP processing on
> before it goes out; unfortunately Apache appears not to know to pass it
> through the PHP handler as it not named *.php so the embedded PHP code
> doesn't get processed.
> 
> I assume I have to do something with Action, AddHandler and SetHandler
> directives, but just what exactly.

When I want to add PHP processing to a file type, I just add the file
extension to the AddType application/x-httpd-php line in my httpd.conf.  You
could do a similar thing with your .css files, but there's a problem -- I
think, by default, any request that gets passed through PHP ends up with a
content-type of text/html no matter what.  Basically, at the time you
delegate responsibility for a file to PHP, Apache says "not my problem any
more" and lets PHP specify the content type.

So, in your PHPified CSS files, you'll need to run something like
header('Content-Type: text/css'); to specify the content-type of the file. 
By the time you do this to all of your CSS files, you're better off (as has
been explained already) putting your dynamic CSS stuff into a .php file,
referencing it in your <LINK> tags as such, and just telling the file to
announce to the world (via the aforementioned header) that it's a CSS file,
and proud!

- Matt

Attachment: signature.asc
Description: Digital signature

-- 
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html

Reply via email to