php - Generate unique URL for each customer downloading the same file -
i need deliver file
example.com/realpathofthe/file.zip
to customers don't want communicate same url customers (they share url non-customers, , difficult track if product delivered or not). instead, i'm generating random string in php , want share such url:
example.com/download/djbf6xu83/file.zip
which different each customer.
question: should generate symlinks each customer link random string path path of actual file on server?
or use rewriterule in .htaccess this? if done way (ie rewrite /download/*/file.zip
actual file), all random strings link same file. not because non customer generate download link himself. how handle correctly?
note: i'd avoid if possible php has process gigabytes of files data (through file_get_contents()
) before delivering it. thought (please correct me if i'm wrong) lighter server let apache distribute file.
there can many ways approach problem. here's suggest. make file, /download.php
, pass in download code http variable. it'd /download.php?code=abcdef
, meanwhile generate , store codes each customer in database, , check if code exists when opens download.php
. easy track, , not creating complex directory structure.
wiki
Comments
Post a Comment