I have image file here
/var/www/img/timetable.jpeg
URL is
www.mydomain.com/img/timetable.jpeg
But I don't want user know the real URL, I want user access the file like this
www.mydomain.com/get/timetable.jpeg
So I use PHP framework to intercept request, e.g. Fat-free
$f3->route('GET /get/@filename',
function($f3) {
$filename=$f3->get('PARAMS.filename');
// here return/redirect the file
}
);
But I don't want to use this way.
$f3->route('GET /get/@filename',
function($f3) {
$filename=$f3->get('PARAMS.filename');
$attachment_location = 'img/'.$filename;
header($_SERVER["SERVER_PROTOCOL"] . " 200 OK");
header("Cache-Control: public");
header("Content-Type: image/jpeg");
header("Content-Transfer-Encoding: Binary");
header("Content-Length:".filesize($attachment_location));
header("Content-Disposition: attachment; filename=".$filename);
readfile($attachment_location);
}
);
I expect something like this, but this is redirect, user will know URL
$f3->route('GET /get/@filename',
function($f3) {
$filename=$f3->get('PARAMS.filename');
header("Location: img/".$filename);
}
);
Can I do that in PHP, is it call Forward
?