Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

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

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

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

share|improve this answer

Assume all files not containing a period are PHP:

      <FilesMatch "^[^\.]+$">
              ForceType application/x-httpd-php
share|improve this answer

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

share|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 :) – drAlberT Sep 1 '09 at 17:35

The 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) should use that file for your local magic definitions only.

share|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

It sounds to me that 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 to be there. Try locate mime/magic if you can't find it at the above location.

share|improve this answer

Your Answer


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.