wierd behavior on css with wamp
Posted by: RalphEs (---.Red-88-28-31.staticIP.rima-tde.net)
Date: August 23, 2009 01:43PM

systems involved

Firefox 3.0.13
Firefox 3.5.2
IE 6

Wamp:
apache 2.2.11
PHP 5.2.9 & php 5.3

I do parse css files through php

Problem: css files are loaded into the browsers but not interpreted or used on RAW HTML files no php included. The html files are produced with phpDocumentor 1.4.2. IE6 uses parts of the css files loaded to display the page, Firefox NOT AT ALL.

I think it might be possible that wamp throughs some wired characters into the css files or is the header type a problem? It looks like parsing the css through the php engine changes the header of the css to text/html. this would explain why IE6 can use them. on the other hand firebug shows the loaded css indicates however that no css is available.

as an reverse check I did load the html files direktly from the disk with file:/// ... and the css are interpreted perfectly. so the source of the problem is wamp.

it seems that the @importcsss does the biggest problem.it creates a 404 error "file not found"

it seems creating dynamic css files got some secrets involved with the wamp. I'm using this concept since ages on linux with no problem.

on the @includecss it seems that the search for files are changing to the php include path or something.

any idear what to check?

is important for my work to create css dynamicly

Options: ReplyQuote
Re: wierd behavior on css with wamp
Posted by: c2dan (---.15-1.cable.virginmedia.com)
Date: August 23, 2009 06:36PM

If you're generating your CSS with PHP you need to send the text/css content type header
header("Content-type: text/css"winking smiley;
That should be the first line in your code after your opening php tag.

Options: ReplyQuote
Re: wierd behavior on css with wamp
Posted by: RalphEs (---.Red-88-28-21.staticIP.rima-tde.net)
Date: August 23, 2009 10:40PM

this is not the point

THE POINT IS THAT STATIC PAGES USING STATIC CSS DON'T WORK.

as soon as I parse .css in apache with

AddType application/x-httpd-php .css

the mime type in the header are changing.

is there any way to configer that PHP does not change the header on files not containing PHP code ?

Options: ReplyQuote
Re: wierd behavior on css with wamp
Posted by: c2dan (---.15-1.cable.virginmedia.com)
Date: August 24, 2009 07:28PM

RalphEs Wrote:
-------------------------------------------------------
>
> as soon as I parse .css in apache with
>
> AddType application/x-httpd-php .css
>
> the mime type in the header are changing.
>

With that you're now telling Apache to send all requests for .css files to the PHP Interpreter. BY default the PHP Interpreter sends back the text/html content type header, even if you've not placed any PHP code within the .css file.

To override the defailt content type sent back by PHP you you must explicitly tell PHP to send back a different content type, using the header() function as I suggested in my earlier post.
header( "Content-type: text/css" ) ;

If you didn't add this line in to the httpd.conf
AddType application/x-httpd-php .css
The all .css files will send back the text/css content type header. All web browsers expects the text/css content type header to be returned when parsing .css files. If it see's the content type as text/html it will parse the file as HTML not CSS.



Edited 2 time(s). Last edit at 08/24/2009 07:34PM by c2dan.

Options: ReplyQuote
Re: wierd behavior on css with wamp
Posted by: RalphEs (---.Red-88-28-11.staticIP.rima-tde.net)
Date: August 26, 2009 10:38PM

this I figured out:

u can use apache to tell PHP on specific files to use a specific deafault content type.

I used the file directive in apache like this: ( http.conv )

<Files ~ "\.css$">
php_value default_mimetype "text/css"
</Files>

and then for parsing the .css files

AddType application/x-httpd-php .css

this is the greatest solution I can guess of

Options: ReplyQuote
Re: wierd behavior on css with wamp
Posted by: yfastud (Moderator)
Date: August 26, 2009 11:51PM

since most people add css right into webpages, not sure what's good when adding type for css in apache's config???

Have fun,

FREE One A Day
FREE Photo
FREE Games
FREE Websites
FREE Portable GPS
FREE WAMP Guides

Options: ReplyQuote


Sorry, only registered users may post in this forum.