Reputation:
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
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
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
Reputation: 2200
What about this - http://httpd.apache.org/docs/1.3/mod/core.html#files
Upvotes: 0