Forum Moderators: phranque

Message Too Old, No Replies

mod rewrite and mp3 files problem

Blocking direct access and download MP3 files blocks Flash-MP3 player

         

Hcharly

3:51 pm on Jul 30, 2006 (gmt 0)

10+ Year Member



Hi all,

I'm trying to get some MP3 files safe in the web environment, using rewriteCond and rules.
The following htaccess seems to block the mp3 downloading and browsing, but the Flash-MP3-player embed in the site, cannot play no more the files. I just need to block the manipulation of these files outside of the web scripts.
I need a help to solve this matter. Sorry for my english.
I've been trying alone since 5 hours.

Thanks so much.

<htaccess>
Options FollowSymLinks
# mod_rewrite in use

RewriteEngine On

RewriteCond %{SCRIPT_URI}!^http://mysite.com/test/index.php$ [NC,OR]
RewriteCond %{SCRIPT_URI}!^http://www.mysite.com/test/index.php$ [NC]
RewriteRule .*\.mp3$ - [F]

RewriteCond %{REQUEST_FILENAME}!-f
RewriteCond %{REQUEST_FILENAME}!-d
RewriteCond %{REQUEST_URI} ^(/test/component/option,com) [NC,OR]
RewriteCond %{REQUEST_URI} (/¦\.htm¦\.php¦\.html¦/[^.]*)$ [NC]
RewriteRule ^(content/¦component/) index.php

</htaccess>

jdMorgan

4:11 pm on Aug 3, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Delete the [OR] flag from your first RewriteCond -- You want to block if the request is (NOT from yourdomain) AND (NOT from www.yourdomain). Also, SCRIPT_URI is not the correct server variable -- it will contain the directory-path and filename of the requested image, which is not what you want.

I'd suggest you rewrite the whole things as:


RewriteCond %{HTTP_REFERER} .
RewriteCond %{HTTP_REFERER} !^http://(www\.)?example\.com/test/index\.php [NC]
RewriteRule .mp3$ - [F]

This code allows blank referers -- an unfortunate necessity. This is described in detail in hundreds of previous threads [google.com] here.

Jim