I just finished something somewhat similar for some cheesy mid files I put back online. More for hot-link protection than for serving additional content, but maybe you could adapt it to your goal.
In the page that has the links to the files
Code:
session_start
if isset session
check db for match
if not within acceptable time frame - unset
if not set
set session
enter info into db
In htaccess (note* not usiing add-type)
Code:
RewriteEngine on
Options +FollowSymlinks
RewriteBase /
RewriteRule ^(regex_here)\.mid$ $1/file_name_here.php
In the file that's redirected to
Code:
session_start
if issest session
preg_match session or unset
check db for match and acceptable time or unset
if isset session
- use $_SERVER["REQUEST_URI"] to get name of file
- serve with header("Content-Type: audio/mid");
if not isset (here's where to get inventive, what I did is:)
- serve random mid file instead of requested file
I think for a redirect you would need to serve the php file as javascript with a location=new_page. You could have that page be a dynamically generated one that has the requested image in it, so the image would be in a page, not by itself.
I don't think you could just use only htaccess to redirect to the new page directly, (not that it can't be done) eg. if someone has a page with
<img src='your_img ...
sending back a page wouldn't go into the tag's src
Alternatives might be creating a new image with the requested image in it, or water-marking.
Bookmarks