Force files to download in certain directory with htaccess






















Your email address will not be published. Save my name, email, and website in this browser for the next time I comment. Toggle navigation. Related posts:. How to Disable TLS 1. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. The Overflow Blog. Podcast An oral history of Stack Overflow — told by its founding team.

Millinery on the Stack: Join us for Winter Summer? Bash, ! Featured on Meta. New responsive Activity page. Linked Related 1. Hot Network Questions. I added this code in a file named.

It clearly states The directives given within this section will be applied to any object with a basename last component of filename matching the specified filename. Evan Donovan 9 9 silver badges 18 18 bronze badges. Perleone Perleone 3, 1 1 gold badge 24 24 silver badges 26 26 bronze badges. Thanks for your explanation. I had looked at the documentation, but it seemed like chinese to me. There really is no way to target a folder through the htaccess folder?

I ended using PHP to set the correct headers to force the download because I couldn't afford to put an. ForceType and Header are enough. This code is perfect if you don't use - in the file name! For example, for name Peter Mortensen A Alireza. A 41 3 3 bronze badges. Sign up or log in Sign up using Google. To match only files contained in a specific directory, simply move the code to the.

If the desired directory does not contain an. Here is another similar example that shows how to force download for multiple file types, plus sends an additional header to make it all good. Here we are matching any file that has an extension of. You can add or remove extensions by editing the regular expression used in FilesMatch.

Additionally, we send along a header that sets the Content-Disposition as an attachment.



0コメント

  • 1000 / 1000