Reputation:
I have a directory on my server which has a bunch of shell scripts. This directory is autoindexed, but when I try to open the files in my browser, they prompt for download instead of opening as text. I can easily map the filetype "sh" to text/plain in the mime.types file, but some of the scripts don't have that sh extension. How can I serve all files in a certain directory as .txt files so that they are opened in the user's browser instead of prompting the user for download?
Edit: adding add_header Content Type text/plain;
to that directory's location block does show all of the scripts as text, but it also affects the autoindex page.
Upvotes: 3
Views: 1071
Reputation: 143
That should be add_header Content-Type text/plain;
(instead of add_header Content Type text/plain;
, right?)
But you're right about it affecting all files. It even renders HTML as plain text and displays the source when visited with a browser. I'm experiencing the same problem as you have (files with many different extensions, most of which plain text)
Upvotes: 2