Htaccess force download files in folder

Htaccess force download files in folder

htaccess force download files in folder

When you use an Htaccess file, you're basically giving special instructions to the Apache web server itself. With the use of the.htaccess file, you can control many aspects of the Apache In theory, every folder (directory) on your server could have one. you could force files with these extensinos to be downloaded automatically. NOTE.htaccess files are for people that do not have rights to edit the main server Custom Error Pages; Force Downloading; Prevent Downloading; Allow Cross-​Domain Fonts Redirect 301 /oldpage2.html http://www.example.com/folder/. htaccess force download files in folder

Htaccess force download files in folder - you thanks

TimeWaster's Place

Nearly every browser will show image oder video files you want to provide for download in the browser itself instead of opening a download dialog.

Most of the websites suggest to use this code in your .htaccess:

<FilesMatch "\.(jpg|zip|avi)$"> ForceType application/octet-stream </FilesMatch>

But this is not enough! Even when the MIME-Type is set to "octet-stream", some browsers will still open the files their selfs because they have detected the .jpg or .avi file extension.

The solution to this is to add the following header:

<FilesMatch "\.(jpg|zip|avi)$"> ForceType application/octet-stream Header add Content-Disposition "attachment" </FilesMatch>

With this header every browser i tested opened a download dialog, regardless of which file extension is present.

To use this, your webserver has to have mod_headers activated (It is most likely already included in Apache, but not activated): Apache Module mod_headers

Источник: [https://torrent-igruha.org/3551-portal.html]

Htaccess force download files in folder

3 thoughts to “Htaccess force download files in folder”

Leave a Reply

Your email address will not be published. Required fields are marked *