Forum Moderators: bakedjake

Message Too Old, No Replies

Changing Mime Type of a File

Is this possible?

         

Nick_W

4:09 pm on Mar 12, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi all,

Is it possbile to change a file from

text/plain
to
text/css
?

I'm having trouble getting NN7 to read css files and when I use the 'file' comand i get

text/plain
for my CSS files and I think this may be the problem...

Many thanks...

Nick

seindal

7:40 pm on Mar 12, 2003 (gmt 0)

10+ Year Member



Apache has a directive that maps file extensions to mime types.

The file program is completely different from apache. It will look into the file and try to match the content against various patterns in an attempt to deduce the mime type of the content.

An easy way to find the mime type of a file as seen by apache is to use "wget -d URL" which will show the entire communication between client and server. Wget is a unix program, but a windows version exists.

René

universalis

8:12 pm on Mar 12, 2003 (gmt 0)

10+ Year Member



I assume your problem is this:

[devedge.netscape.com...]

Are you using Apache? If so, in the .htaccess file in your web root, add this line:

AddType text/css css

Problem solved!

Hope this helps...

Nick_W

8:21 pm on Mar 12, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hmmmm.. tried the .htaccess thing. I understand the principle and can't see why it wont work...

Just wondered if there was a way to physically change the Mime type?

Thanks guys!

Nick

seindal

9:03 pm on Mar 12, 2003 (gmt 0)

10+ Year Member



Just wondered if there was a way to physically change the Mime type?

The mime type is not a property of the file. It is something that is associated with the file through some process of examination of the file. Apache uses the file name extension, the file program the first part of the files content.

So there is not way to change it. You can, however, influence the process of assigning a mime type to the file, by setting apache directives or by renaming or editing the file.

René.

dingman

1:34 am on Mar 14, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I don't know what your hosting setup is, so I don't know if you can do this, but you might try making entries in /etc/mime.types or /etc/apache/mime.types. (On my system, the latter is a symlink to the former) The line you want is

text/css css