mercredi 2 juin 2021

NGINX serve all files in certain directory as txt files, but not autoindex pages

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.




Aucun commentaire:

Enregistrer un commentaire