NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
mime types - winxp + firefox + xhtml + css


Joined: 11 Jul 2007
Posts: 32
Reply with quote
hi,

how to make winxp+nusphere php to serve css files as text/css and not text/html?

Not usually a problem that it does serve .css files as 'text/html', until using firefox and the file declaration is xhtml in which the css file is called from.

firefox http live headers shows that:
Code:

http://localhost:8080/path/Default5.css

GET /path/Default5.css HTTP/1.1
Host: localhost:8080
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.18) Gecko/20081029 Firefox/2.0.0.18 (.NET CLR 3.5.30729)
Accept: text/css,*/*;q=0.1
Accept-Language: en-gb,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://localhost:8080/path/page.php
Cookie: cisxvisitor=wfpsgfscthkpcvdh; DBGSESSID=-1


HTTP/1.x 200 OK
Connection: keep-alive
Content-Type: text/html
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Date: Tue, 01 Dec 2009 11:31:50 GMT
Expires: Thu, 19 Nov 1981 03:00:02 GMT
X-Powered-By: PHP/5.2.11
Set-Cookie: DBGSESSID=-1; path=/;
Transfer-Encoding: chunked
Server: Srv/5.9.0.5916



looking at errors in ff:
Code:

Error: The stylesheet http://localhost:8080/path/Default5.css was not loaded because its MIME type, "text/html", is not "text/css".
Source File: http://localhost:8080/path/page.php
Line: 0


Thanks

William.
View user's profileFind all posts by WilliamSend private message


Joined: 11 Jul 2007
Posts: 32
Reply with quote
do I need to edit:
C:\Program Files\NuSphere\PhpED\config\srvmime.cfg
(currently empty) with an entry for css files?
if so what is the format for entries into this file?
View user's profileFind all posts by WilliamSend private message


Joined: 18 Dec 2011
Posts: 1
Reply with quote
Did you ever figure out a solution to this issue? I am having the same problem...
View user's profileFind all posts by edwaaSend private message


Joined: 11 Jul 2007
Posts: 32
Reply with quote
I am not sure of solution/problem (It was two years ago)

a possible solution maybe adding the following?
<meta http-equiv="Content-Style-Type" content="text/css" />
View user's profileFind all posts by WilliamSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8335
Reply with quote
It seems is your mistake. If you don't output the content type header, php WILL ADD it for you and the default content type is of course text/html.
So, if you process CSS or JS, you have to add header('Content-Type: text/css') or header('Content-Type: text/javascript') respectively and of course the header must the the first output in your script.

For further details please check php manual:
http://php.net/manual/en/function.header.php

btw, I'd recommend never process CSS or JS in php. It's better to leave them static (e.g. files). Scripts that you output from php won't be cached on the client, so they will re-run for each page the client requests. This would slow down appearing of the page in the browser and may bring some side effects. Finally, there is no reason to add anything for CSS or JS in php.

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website
mime types - winxp + firefox + xhtml + css
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic