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.

  • 1
    Is the file /etc/magic actually the right location on your system for the MIME magic file?
    – David Z
    Aug 18, 2009 at 5:16
  • 1
    Mind that mod_mime_magic only kicks in if mod_mime does not find a MIME type for a file. In case of no extension, mod_mime finds many MIME types from /etc/mime.types, causing mod_mime_magic to not ever being called, but also not one type being determined. Mar 3, 2017 at 11:09

5 Answers 5


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.


Assume all files not containing a period are PHP:

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

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


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.

  • 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. Aug 18, 2009 at 17:16
  • oops, I mean text/plain Aug 18, 2009 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. Aug 18, 2009 at 17:19
  • And that only seems to be on some files. Aug 18, 2009 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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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