Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am trying to get all the files in a particular folder to force download:

I created a .htaccess file but this does not work

AddHandler cgi-script .php .pl .py .jsp .asp .htm .shtml .sh .cgi 
Options -ExecCGI

Basically, I don't want any script or anything to execute. I want everything to download from that folder.

Any suggestions?

share|improve this question

2 Answers 2

up vote 2 down vote accepted

You can do it on an extension by extension basis with AddHandler

AddHandler default-handler php pl py jsp asp

However this is cumbersome as you need to keep on top of every possible extension. You can set the default handler for every file within a htaccess file with SetHandler. And this would be my preferred method. Simply enter this into your htaccess file.

SetHandler default-handler

If you don't have permissions to do this in your htaccess, you'll need to get it entered in a Directory directive in your Apache configuration:

<Directory /path/to/dir>
    SetHandler default-handler
</Directory>
share|improve this answer

A simpler solution to download ALL the files in a folder.

.htaccess in that folder

Header set Content-Disposition attachment

But this needs Headers module to be loaded in apache

LoadModule headers_module modules/mod_headers.so 

and one more thing Browser cached images won't download.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.