Mar
19
Force Files Like PDF Download using htaccess
March 19, 2008 |
Sometimes you want files in certain format like PDF to be downloaded instead of opened in new browsers. Because such files normally have very large size and may cause your browser run out of memory. With Apache .htaccess, file force download can’t be easier. See the example below:
<FilesMatch "\.(pdf|mp3)$">
ForceType application/octet-stream
</FilesMatch>
This example will download all pdf and mp3 files when directly linking to them. If you view them in a web page, they will display, but if linked directly to them they will show you the save box. (Files don’t seem to download if they are saved in cache Ctrl+F5 to fix that).
Similar Posts
- htaccess Explicitly Define Default Index File
- Deny Access to inc Files Using htaccess
- Create Custom Error Pages Using htaccess PHP
- htaccess Permanently redirect file or directory
- Use htaccess for 404 Redirect
- htaccess gzip for Faster Loading and Bandwidth Saving
- Apache htaccess Prevent Users from Uploading and Executing Files
- Use htaccess to Deny Access to hidden Files
- Use htaccess with Site Maintenance Page
- htaccess Require the www For Domain URL
- Google Text Translation Using htaccess
- htaccess Remove the www From Domain URL
- Use htaccess to Fake Different File Extension
- htaccess Deny Diractory Access During a Specific Time
- Block IPs Using htaccess
- Block people from Certain URL Using htaccess
- Set Local Timezone Using htaccess
- Remove File Extension Using htaccess
- htaccess Conditional Loop Redirect
- htaccess Limit the Number of Concurrent Visitors to your Website
- Use htaccess to Deny Access Directory Listing
Comments
1 Comment so far



































this is not working want to use this.
ForceType application/pdf
Header set Content-Disposition attachment