Forcing An Anchor To Download

Forcing An Anchor To Download

In developing the VLSITools.com website, I ran across a problem when trying to make Python scripts available for download.  Whenever an anchor was clicked on that linked to a Python script, the server would try to execute it and dump out an Error 500.  What I want instead is for the script to download as a normal “non-script” file.  After a little searching, I came across this tip which should work for any server running Apache.  Simply add the following line to your .htaccess file (if you don’t have one, just make it) :

AddType application/octet-stream .py
Of course, you can add as many extensions as you’d like.  I now have a top level .htaccess (since it propogates down through the directory hierarchy) with entries for .py, .va, .m, etc.  Works like a charm.