serhii.net

In the middle of the desert you can say anything you want

22 Apr 2023

Make files downloadable in an Apache webserver and HTML

Problem: jupyter notebooks being shown as text on my website.

Adding the following to a .htaccess file prevents files being “shown” in the browser, as opposed to downloaded1:

<FilesMatch "\.(?i:doc|odf|pdf|rtf|txt|ipynb)$">
  Header set Content-Disposition attachment
</FilesMatch>

Also 2 that there’s a HTML syntax for that in links now!

<a href="./my_file.txt" download>
Nel mezzo del deserto posso dire tutto quello che voglio.