I am working on a web application that need to serve a number of continuously updated documents at static URLs, but the Content-Type of the documents differs (it's either JPEG or SVG). If the document is a symbolic link, the file at the end of the link has the correct file extension for MIME type mapping, but I have not been able to tell if it is possible to get Apache to follow the link before looking the extension up in the MIME table.
This question asks the same thing, but the workaround provided doesn't work for me, as browsers do not autodetect SVG if I serve image/jpeg (they do autodetect GIF and PNG), so I need a proper MIME type.
Normally, I would use .meta files and mod_cern_meta for this, but my target Linux distributions (Fedora 19/20, RHEL 7) does not come with this, and I would like to avoid having to supply it myself. I don't think I can use mod_headers, since it would require me to rewrite the entire .htaccess file (the files are changed on an individual basis), nor mod_asis, as the data files themselves are generated using a third-party tool.
Edit: I am working around this by writing my files as type-maps (with one entry only), pointing to the actual resource and listing its Content-Type. It means having to write extra files, but so would using mod_meta. Works well enough for the time being.
have you tried mod_mime_magic? with this module enabled, apache can guess the content type the same way "file" command does and will set the content-type header correctly.
Checking the default configuration for a centos httpd installation, mod_mime_magic seems to be enabled by default and the content-type is set correctly when (for example) the request targets a symlink (namely "aaaa") for a, let's say, .png file.
Also, make sure you have followsymlinks option enabled for the root directory containing the symbolic links (or just enable it for the entire documentroot)
I'm going to include for brevity some configuration hints for apache httpd to make mime magic work:
How about making your static URLs not point directly to the documents, but to a simple script that sets the correct Content-Type header and then streams the document?