I have some old HTML files that were created elsewhere by someone else. Many of them don't, for some reason, have the .html extension on them. I don't want to have to change them if possible, but for some reason Apache can't seem to do any MIME magic to figure out their file type. I have the *mime_magic* mod enabled, along with the following in the sites section:

    MimeMagicFile /etc/magic

I should note that I'm using Debian Linux on this machine.

link|improve this question
1  
Is the file /etc/magic actually the right location on your system for the MIME magic file? – David Zaslavsky Aug 18 '09 at 5:16
feedback

5 Answers

I tried the DefaultType workaround in my main conf file and it did not work for me. (My environment is an internal, thoroughly hacked-up version of Apache, so there may be a FileInfo directive or something overriding DefaultType and I can't find it. On standard installations it may work...)

What DID work: since all the extensionless files I'm dealing with are in one known directory, I added a Location block and used ForceType:

<Location "/directoryname">
ForceType text/plain
</Location>

You cannot use ForceType on a directory that should contain more than one type of file.

link|improve this answer
feedback

magic file path is /usr/share/file/magic in debian. Change the configuration statement to

MimeMagicFile /usr/share/file/magic

if you open /etc/magic with a text editor, you can see the comment explaining that file(1) would use that file for your local magic definitions only.

link|improve this answer
It seems like this should work, but Apache is still giving text/html for those files, and I just double checked to make sure the file is there. – supercheetah Aug 18 '09 at 17:16
oops, I mean text/plain – supercheetah Aug 18 '09 at 17:17
Actually, I think I take that back. It might be something with Firefox because I just checked this with Chromium, and it seemed to work just fine. – supercheetah Aug 18 '09 at 17:19
And that only seems to be on some files. – supercheetah Aug 18 '09 at 18:31
feedback

A simple warkaround, not really a solution maybe, would be to change the DefaultType as follows:

DefaultType text/html

This would assure every non recognized file will be treated as html.

This is not a true solution, I repeat, but it is simple and may have sense if your server serves mainly html contents

link|improve this answer
Didn't you mix up something? You probably mean DefaultType text/html – sleske Sep 1 '09 at 15:51
Yep :) ... even if html is in fact plain text files :) – AlberT Sep 1 '09 at 17:35
feedback

It sounds to me like you are using the SYSTEM magic file when you want to be using the MIME magic file -- as the name of the Apache configuration directive "MimeMagicFile" implies. Try this:

MimeMagicFile /usr/share/mime/magic

Of course, make sure that is the right path for your system -- I don't have a Debian system to test with, but I would expect it will be there. Try "locate mime/magic" if you can't find it at the above location.

Sean

link|improve this answer
feedback

Assume all files not containing a period are php ...

      <FilesMatch "^[^\.]+$">
              ForceType application/x-httpd-php
      </FilesMatch>

Eugene.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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