user381800
user381800

Reputation:

htaccess or other method to prevent zip file download?

Is there a way to prevent users to directly download zip files from server? I try adding deny all in the htaccess but all that does it prevent the user from browsing the folder content. They are still able to directly type in the browser http://site.com/file.zip and it would download..

Any ideas?

Upvotes: 0

Views: 3713

Answers (4)

Shelwien
Shelwien

Reputation: 2200

If htaccess doesn't really work, then what about setting permissions to these files like to 600 or something? I mean unix r/w permissions, you can change them via ftp etc. And unless webserver works under your account, it won't be able to access them.

Upvotes: 0

Bazzz
Bazzz

Reputation: 26922

Use mod_rewrite to rewrite any url that ends in .zip to the page that does the authorisation and then in the authorisation page use passthru() to provide the zip file.

Something like this (might not work out of the box, merely to give you an idea):

RewriteRule ^(.*?\.zip)$ authMe.php?url=$1

Have a read here: http://httpd.apache.org/docs/current/mod/mod_rewrite.html

And here: http://php.net/manual/en/function.passthru.php

Upvotes: 2

Shelwien
Shelwien

Reputation: 2200

What about this - http://httpd.apache.org/docs/1.3/mod/core.html#files

Upvotes: 0

GolezTrol
GolezTrol

Reputation: 116140

You can password protect a directory and put the zipfile in that directory. A comprehensive guide how to do that is here.

Upvotes: 0

Related Questions