On Wed, 2004-11-10 at 07:39, [EMAIL PROTECTED] wrote:
> Howard Lowndes wrote:
> > On Tue, 2004-11-09 at 10:37, Matthew Palmer wrote:
> > 
> >>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!
> > 
> > 
> > I can see what you are saying here, and I have the line in my
> > <head></head> block that reads:
> > <link> rel="stylesheet" type="text/css" name="cssname.php"</link>
> > which is what I think you are saying but when the file name ends in .php
> > it seemingly ignores the "type" statement so I guess PHP must be sending
> > out different mime type headers, and it looks like I will have to do as
> > Amos suggests.
> 
> I'm not sure about the rest but I think he made it pretty clear that you
> can add a php command like:
> 
> header('Content-Type: text/css');
> 
> at the very beginning of the CSS file (before a buffer gets flushed).
> (that's the PHP command I didn't know due to lack of experience with
> PHP).
> This will set the HTTP header of the response when the server sends
> away the CSS file after it was processed by PHP, which seems to be
> what eventually the browser looks at.

Yes that is the way I went - it works fine - tks to all.
> 
> Cheers,
> 
> --Amos
-- 
Howard.
LANNet Computing Associates;
Your Linux people <http://www.lannetlinux.com>
------------------------------------------
"When you just want a system that works, you choose Linux;
when you want a system that just works, you choose Microsoft."
------------------------------------------
"Flatter government, not fatter government;
Get rid of the Australian states."


-- 
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