1

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.

spitemim
  • 155
  • 1
  • 6
  • This is behaviour of your browser use command line tool like curl if you want to get text output. Certain file like pdf, jpg are opened whereas other are downloaded – Rajesh Paudel Jun 02 '21 at 15:08
  • Does this answer your question? [How to add headers to only specific files with nginx](https://stackoverflow.com/questions/16945223/how-to-add-headers-to-only-specific-files-with-nginx) – Rajesh Paudel Jun 02 '21 at 15:26
  • Use: `types {}` and `default_type test/plain;` – Richard Smith Jun 02 '21 at 15:36

0 Answers0