Results 1 to 10 of 10
  1. #1

    Quick .htaccess question

    Hi everyone,
    I have what is probably a simple question about mod_rewrite.

    I am trying to disable hotlinking for mp3 files, unless it is a swf file on my site trying to play the file.

    I tried this:

    RewriteCond %{HTTP_REFERER} !^http://(www.)?\?file=.*$ [NC]
    RewriteRule .*\.mp3$ - [F,NC]
    For example, I want to disallow hotlinking to but I want to be able to play the file. Currently, my server won't let musicplayer.swf play music.mp3.

    If you could please help me understand what I am doing wrong that would be great! Thanks!

  2. #2
    Hi hosty567,

    With a quick google search, I found this:

    RewriteEngine on

    RewriteCond %{HTTP_REFERER} !^$

    RewriteCond %{HTTP_REFERER} !^http://(www.)?*$ [NC]

    RewriteRule \.(gif|jpe?g|png)$ - [F]

    Just insert mp3 in the RewriteRule and it should work. This is where I found the info:

  3. #3
    Thank you for your response. I have tried that one before but it doesn't work. In a previous thread, I had asked how to stop hotlinking of jpgs and this works:

    RewriteEngine on

    RewriteCond %{HTTP_REFERER} !^*$ [NC]
    RewriteCond %{HTTP_REFERER} !^$ [NC]
    RewriteCond %{HTTP_REFERER} !^*$ [NC]
    RewriteCond %{HTTP_REFERER} !^$ [NC]
    RewriteRule .*\.(jpg|jpeg|gif|png|bmp|wmv|css|js)$ - [F,NC]

  4. #4

  5. #5
    I think I did try that. But anyway I'm just storing my mp3s in a database. It might not be the best way but they are small files and there are only about 150 of them. Thanks for all your help!

  6. #6

  7. #7
    That's ok, you didn't have to help me at all. I think the problem is that Flash files don't give a referrer when they open a URL. I've been googling and it seems that's the problem.

  8. #8
    Join Date
    Mar 2003
    Moved > Technical & Security Issues.
    Specially 4 You
    JoneSolutions.Com ( Jones.Solutions ) is on the net 24/7 providing stable and reliable web hosting solutions and services since 2001

  9. #9

  10. #10
    Yeah it's really a pain.

Similar Threads

  1. htaccess question
    By Mekhu in forum Hosting Security and Technology
    Replies: 5
    Last Post: 10-03-2008, 12:40 AM
  2. another htaccess question
    By samdax in forum Programming Discussion
    Replies: 10
    Last Post: 11-19-2007, 05:05 AM
  3. .htaccess Question..
    By InvisionSrv in forum Hosting Security and Technology
    Replies: 5
    Last Post: 08-30-2005, 08:32 AM
  4. htaccess question...
    By theqase in forum Hosting Security and Technology
    Replies: 8
    Last Post: 07-21-2005, 05:56 PM
  5. Question on htaccess
    By jmc67 in forum Hosting Security and Technology
    Replies: 2
    Last Post: 08-27-2004, 06:56 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts