0

I am new to Apache. I have almost no knowledge of apache. I am using apache 2.2.11.
I have one css file and multiple .js files which i am uploading to a remote storage with a php page(PHP - 5.2.8). When i am using function mime_content_type to get the mime type of css.css file, i am getting text/plain. Same issue with .js files. There are some image files for which mime-types returned are correct with the same function.

I have checked that server has text/css css defined in mime.types file. The incorrect mime-type is creating issue for me and i have spent a lot of time with no success.

Any help?

Ruchit Rami
  • 333
  • 1
  • 8
  • 15
  • Seems like a better fit for http://webmasters.stackexchange.com/ – dunxd Dec 14 '12 at 11:49
  • @dunxd Well i feel this issue has more to do with my server. The file is .css and the mime type i am getting for it on server is text/plain. – Ruchit Rami Dec 14 '12 at 11:54

2 Answers2

2

For one, note that PHPs mime_content_type applied to files by their content is a different story than the mime type served by Apache to clients by their file extension. Then, mime_content_type seems to be deprecated in favour of fileinfo. But the really crucial thing is: The content of a css file is not necessarily detectable as CSS (and not just plain ascii text). This is different from html, which can be recognized from the distinctive first characters of content (e.g. "<HTML") and therefore are recognized as text/html. Thus, there is no sufficiently straigtforward way to know by the content that the file really is CSS and not just plain ASCII text. I suggest you rely on the file extension to override the text/plain results.

Hagen von Eitzen
  • 824
  • 3
  • 17
  • 43
0

From the PHP documentation for mime_content_type function:

string mime_content_type ( string $filename )

Returns the MIME content type for a file as determined by using information from the magic.mime file.

dunxd
  • 9,632
  • 22
  • 81
  • 118