Ftp – How to configure Web/FTP Server so that it downloads .sh files instead of showing its content

ftp

I have an FTP server (vsftpd) where there are many files of various types. Normally when you click on .tar.gz file in your browser, it starts downloading it.

The problem is when user clicks on .sh file, the file is not downloaded but instead its content is displayed in the browser.

What should I configure FTP or Web server to force it to download .sh files?

Edit: First, Web server is Apache. However, as I understood, Web server doesn't interfere with the request as "ftp://" protocol is used instead of "http://". Perhaps, this is the reason Apache's rules are ignored (because Apache doesn't receive any request). FTP server directly handles all the client requests.

Considering all these. Is there a way to configure FTP server to correctly handle .sh files?

Best Answer

In Apache, you can do the following to force even the most reluctant of web browsers (I'm looking at you, IE) to download a file:

<FilesMatch *.sh>
  ForceType application/octet-stream
  Header set Content-Disposition attachment
</FilesMatch>

This should be added inside either a VirtualHost, or a Directory within a VirtualHost.

Related Topic