Reputation: 1200
I asked this question in a different form. Now that the problem is clearer, I'm adding it in this form:
would like to run an auto_prepend_file script (or some equivalent) for binary files (mp3).
If I try to use an Addhandler to treat the mp3 as php, will get all kinds of errors since php will try to parse the mp3 file.
Is there some equivalent way to run an auto_prepend_file for binary files?
(I cannot use mod_rewrite)
Upvotes: 0
Views: 917
Reputation: 8685
If you can use .htaccess
, you could simply force the prepend file for any kind of request:
php_value auto_prepend_file "prepend.php"
And then in the prepend.php
check what was requested and either do something (if it is mp3 for example) or not (for any other kind of files)
Update:
OK, for non-PHP files it does not work automatically, but you can do following trick (though its not that nice solution):
In .hatccess
force your mp3
file to be treated as PHP
:
AddHandler php5-script .mp3
php_value auto_prepend_file "prepend.php"
And then in prepend.php
:
// your custom logic here...
header(/* your headers here */);
readfile($_SERVER['SCRIPT_FILENAME']); // serve the requested file
exit(0);
In this way it should work (tested with a PNG file)
Upvotes: 1