Httpd – Apache treating files with “.var[.]” in their names as type-maps

apache-2.2configurationhttpdmime-type

So today at work I ran into a strange problem. An application I was writing had a JavaScript file named form.sales.var.js, placed in the same directory as other JS files. However, when the browser tried to load the JS file, the server returned a 500 Internal Server Error page. The Apache log showed the entry:

Syntax error in type map, no ':' in /var/www/...

—followed by the rest of the file path and the file's contents.

I did some research on Google regarding the issue and found that this was likely caused by the filename containing .var., causing Apache to treat it as a type-map. Since it wasn't, a syntax error occurs.

My questions now are:

  1. Why is a .js file being treated as a type-map when the documentation says that type maps are *.var files? Is it just that my web server is misconfigured, or can others test to see if their web servers produce the same errors with files named something.var.something?
  2. Why is there no documentation of this problem, and why is it so rarely reported, even though this behavior seems to have existed since Apache 1.3? It seems like it would be a more common issue.
  3. Are type-maps commonly used? Is there any foreseeable issues with disabling them in Apache?
  4. What is the best way to address this issue (aside from renaming the file and not using any filenames that contain .var.)?

Best Answer

That's part of Apache httpd's Content Negotiation. Just remove the handler for type-map for the <Directory> or <Location> of your JavaScript files or remove MultiViews for these directories.