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.
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:
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:
A simple warkaround, not really a solution maybe, would be to change the DefaultType as follows:
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 toIf you open
/etc/magic
with a text editor, you can see the comment explaining thatfile(1)
should use that file for your local magic definitions only.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:
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.