Q: How do I change the MIME type of a file served by web.mit.edu?
Answer
Web servers maintain a mapping of file extensions (e.g. .txt, .zip, .jpg) to MIME types. When you download a file or view a document on the web, the web server sends the MIME type, which tells your web browser how to handle the file. For example, your web browser knows that it can display JPEG images, plain text, or HTML files, but that if it receives a .zip file, it should instead offer to save it locally on your computer.
Sometimes, the web server cannot determine the type of a file (such as when a new file type is introduced with a new product), and it must instead guess how to server the file. Occasionally, web.mit.edu may guess incorrectly, and will default to the MIME type text/plain for unknown files. When this happens, instead of downloading a file, your browser window may fill up with nonsensical symbols and letters.
You can force web.mit.edu to serve the file a certain way based on the file's extension. (If the file does not have an extension, you must assign it one.) This is done in the .htaccess.mit file, with the {[AddType}} directive:
AddType mime/type extension
The mime/type must either be the registered MIME type for the file, or application/octet-stream which tells the web server to serve the file as binary data, thereby directing most web browsers to save the file locally. extension is not limited to three characters e.g., if your custom program creates files with the extension ".xyz", you could force them to be served as binary data with the following in your .htaccess.mit file:
AddType application/octet-stream xyz