Tuesday, December 2, 2008

Make files in your webserver download instead of being displayed


Suppose, you have a text file in your web directory. When you access that file, it will be displayed in the web browser itself. If you want to make that file (or any other file type you want) to be asked to download instead of being displayed, here is what you can do:

Create a .htaccess file in that directory with the following content:
AddType unknown/nothing pdf
AddType unknown/nothing txt
AddType unknown/nothing jpg
Now when you access any file with an extension .jpg or .pdf, your browser will ask you to download the file instead of showing up.

0 comments:

 

A Linux Admin's WeBlog! Blak Magik is Designed by productive dreams for smashing magazine Bloggerized by Ipiet The Blog Full of Games © 2008