I have a site that serves media, and I want to restrict access to the raw files and ensure all requests for the files are going through a PHP script first (for logging, authentication, etc.). I have this working well by using .htaccess in Apache to take a file request, and convert the incoming request to a PHP script. The script then logs the request, and uses Header() to redirect the user to the location of the actual file.
The problem, however, is that I am finding many browsers will display in the URL field the endpoint of the redirect and I have found users who will just cut & paste this URL directly into their website, thereby bypassing the PHP script.
What I'm trying to find is a way to do this that masks the actual file location from view from a browser, but still allows me to use my existing PHP script to log the request and then redirect the user to the file (the files are located on different servers and I need to have those server's Apache web servers actually serve the physical files).
Does anyone know a way to mask a redirect in PHP, or have any suggestions on how this could be done? I'm open to using any technologies within the Apache space also if that would help.
Thanks in advance for any suggestions.
Vlad