Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
    
Seems like a better fit for 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
add comment

2 Answers

up vote 2 down vote accepted

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.

share|improve this answer
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.