I'm trying to add some rewriterules in the .htaccess file to deal with hotlinked images - specifically I want to add the URL from the post where the image appeared to the header location information of the hotlinked image request.
I've got working htaccess & PHP code to add the header info, but in order to make it work, I need to be able to somehow look up the URL for the post from the image URL (this blog has a unique post for each image). I've got working code to do this, but it uses the Wordpress API, and when I try to call it none of the functions are recognized.
I'm thinking that maybe calling the API from htaccess isn't possible... like it's out of scope, or I'm calling from a place that can't see Wordpress or something? I'm wondering if there's a way to make Wordpress API calls accessible from htaccess - or if anybody has any suggestions for a workaround.
The only thing I can think of would be to try to query the database directly through MySQL, but I'm a bit nervous about doing that, and I'm not quite sure I understand the data structure fully.
Any suggestions would be welcomed!
wp-load.php
file from the root of your WordPress installation to access the WordPress API