Force Downloading - .htaccess

<FilesMatch "\.(pdf|xml|mp4)$"> ForceType application/octet-stream Header set Content-Disposition attachment </FilesMatch>

3 Responses

Sometimes you want to force the browser to download some content instead of displaying it. The above snippet will help.
Files with (pdf|xml|mp4) only.? So mean I can add more right.? (pdf|xml|mp4|docx|etc)? Right.?
Yes. Add only file extension without dot at beginning. All this file will pop-up in browser for download only. It won't open in browser.

Write a comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.