.htaccess
Code:
RewriteEngine on
RewriteRule vids/(.*) /video.php?video=$1 [L]
video.php
Code:
<?php
$filename = "/var/www/domain.com/" . $_REQUEST['video'];
if ( (preg_match("/[a-z0-9\-_]+.(mp4|wmv|mp4a)/i",$_REQUEST['video'])) &&
(file_exists($filename)) ) {
header("Content-Type: " . mime_content_type($filename));
header('Content-Disposition: attachment; filename="' . $_REQUEST['video'] . '"');
$file=fopen($filename,"rb");
fpassthru($file);
close($file);
} else {
print "error retrieving file";
}
?>
Not a lot of error checking in it, file paths will need to be changed, but, this is probably the basics of what you're looking for. Mimetype detection will help, you can fix the preg_match to match the extensions you want to allow. filenames cannot contain more than one . and must be comprised of all letters, numbers, - and _.