I have a music website where I put some tracks up for streaming, using
Odeo (www.odeo.com). Assuming my website is www.rockmusic.com, all the
.mp3 files are in www.rockmusic.com/audio. I don't upload the tracks
to Odeo, I just use their "link to audio" option, which will embed a
flash player on my website that'll stream the mp3's straight from my
server. Here's the odeo.com embedded code:
<embed src="http://odeo.com/flash/audio_player_tiny_black.swf"
quality="high" width="145" height="25" name="audio_player_tiny_black"
align="middle" allowScriptAccess="always" wmode="transparent"
type="application/x-shockwave-flash"
flashvars="audio_id=3920973&audio_duration=
256.0&valid_sample_rate=true&external_url=http://www.rockmusic.com/audio/Rock
Song.mp3" pluginspage=" http://www.macromedia.com/go/getflashplayer"
/></embed>
That is working just fine, but www.rockmusic.com/audio is open,
meaning anybody can go there and download all the mp3's. Even worse,
people are starting to hotlink to the mp3's in there.
First thing I tried to do was password protect /audio using .htaccess.
I did just that, using an excellent tutorial on wikipedia
(http://en.wikipedia.org/wiki/Htaccess ). It did solve the problem,
except that the odeo flash player wouldn't work anymore, and thus I
had to take it back.
What I'm trying to accomplish here is:
1) Forbid direct navigation to www.rockmusic.com/audio (either by
password protecting it or by redirecting it to www.rockmusic.com)
2) Forbid hotlinking to anything in www.rockmusic.com/audio
3) Allow the odeo.com flash player to access the mp3's in www.rockmusic.com/audio.
4) Accomplish 1, 2 and 3 with a single .htaccess file on the root dir
of my web directory.
I don't know what version of Apache my server runs, but I'm hosted by
Dreamhost, just in case that helps.
By following another worthy tutorial (
http://underscorebleach.net/jotsheet/2004/11/stop-image-hotlinking-tutorial-htaccess-apache)
I ended up with this .htaccess file, but it doesn't do what I want:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !odeo\. [NC]
RewriteCond %{HTTP_REFERER} !google\. [NC]
RewriteCond %{HTTP_REFERER} !search\?q=cache [NC]
RewriteRule (.mp3) http://www.rockmusic.com/images/no_hotlinking.gif [R,NC,L]
If anyone can help, it will be greatly appreciated.. I don't earn a
buck with my website, and it consumes way too much time, but even so I
can't get this thing to work right. Thanks a lot!
Regards,
Bruno |