How did you do the ACLs for media files? is there any code online for this? Thanks!
That way your dynamic script is only responsible for access control and generating headers.
Apache supports similar functionality by setting a Location header on a 200 response from a CGI or mod_wsgi script.