Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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
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/ 

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

share|improve this answer

Your Answer


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.