Forum Moderators: phranque

Message Too Old, No Replies

limit downloads with .htaccess

         

netzoner

10:39 am on Oct 28, 2005 (gmt 0)

10+ Year Member



hi
is their a way to limit the user downloading any file in specific folder in my website using .htaccess
like i want to allow two downloads at the same time it dose not mater who is downloading only two
and any other request for download while the two client are downloading he will be redirected to
a page in my website stating that the allowed numbers of download is full

your help in this matter is highly appreciated

jdMorgan

1:40 am on Oct 29, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



netzoner,

Apache .htaccess runs for each and every request (each individual page, image, script, media file, etc.) to your server. It has no "memory" of any transaction that came before, since HTTP is a 'stateless' protocol and since multiple server instances are running simultaneously. Apache receives a request, serves content in response to that request, and forgets all about it.

Therefore, there is no way to 'count' accesses at the Apache server level. You will need to use a script, and a database and/or session cookies to handle the problem you describe. It is not a particularly easy problem to solve, especially if two or more requests from the same user arrive at your server simultaneously.

Jim