Question (see below for longer explanations and things I have tried already) :
Is there a way of having the short URL http://example.com/qf56p9z redirect to the first file found on the server of the form /files/qf56p9z_(.*), and having it downloaded on the client with filename = (.*) ? (if possible, without PHP)
Background :
I have a file on server stored in /files/qf56p9z_blahblah.xls that I would like to be accessible from this short URL :
(+the same for other thousands of files)
Moreover, I would like that when the user goes to this URL, the file will be downloaded on the client computer with the original filename, i.e. blahblah.xls.
This may be possible with PHP, I tried things like (this could be easily automated for each of my thousands of files) :
<?php
header('Content-type: ...');
header('Content-Disposition: attachment; filename="blahblah.xls"');
readfile('qf56p9z_blahblah.xls');
?>
But I see two problems with this method :
For each reading of the file by a client, PHP has to load the whole file in memory, and output the new file. This is much more CPU/memory consuming than if apache has just to send the file, without PHP
If one day I host all those files elsewhere (on Amazon S3 for example), the file will have to do this route :
Distant-Hosting (AmazonS3) ==> my server/header modified with PHP ==> clientIt is a shame that the data has to do this instead of :
Distant-Hosting (AmazonS3) ==> client