Hi there,
New here, but only to mod_rewrite. I've been reading about it all over the web, but there's so much misinformation out there...
Anyway, to cut to the chase, I've configured my local Apache server (v1.3.33) to use mod_rewite. I'm trying to debug a condition/rule there before deploying it to my actual hosting service, and having zero luck. What I want is to make it so that users can't hot link to .mp3 files I'm hosting. So I've got a dir called:
localhost/music
and I've put the following rewrite stuff into the .htaccess file there:
# Prevent hot linking to all music!
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http://localhost/ [NC]
RewriteRule ^(.*)$ - [F,L]
So basically, I'm trying to say that if the HTTP_REFERER is not an internal link from my site, then take the user to the Forbidden page.
I've debugged the referer that I want to allow with PHP, and I get this:
http://localhost/myTracks.php
So... why on earth won't that regex in the RewriteCond work?! What happens is that when I try to directly access the music via:
http://localhost/music/.../TrackName.mp3
I get the desired result, the user is forbidden access. But when I try to access it via an internal link from localhost, the same thing happens :-\ I'm darn sure that mod_rewrite is configured correctly, because when I try this condition:
RewriteCond %{HTTP_REFERER} ^garbage [NC]
The RewriteRule doesn't kick in. Any ideas as to what I might be doing wrong? And... if it's not something obvious, is there any way for me to get the HTTP_REFERER variable into the Apache logs so I can see what Apache thinks it is?
Thanks in advance,
Steve