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:

    Code:
    RewriteCond %{HTTP_REFERER} !^http://(www.)?mysite.com/niftyplayer.swf\?file=.*$ [NC]
    RewriteRule .*\.mp3$ - [F,NC]
    For example, I want to disallow hotlinking to www.mysite.com/music.mp3 but I want www.mysite.com/musicplayer.swf?file=music.mp3 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.)?your-domain.com/.*$ [NC]

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

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

    http://www.besthostratings.com/artic...t-linking.html
    CIRRACORE
    http://www.colocube.com
    Enterprise and Private Cloud Services, Dedicated Servers, Fully Managed Servers, Colocation Rack and Cage Space, Tier 1 Bandwidth
    sales@cirracore.com

  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} !^http://mysite.com/.*$ [NC]
    RewriteCond %{HTTP_REFERER} !^http://mysite.com$ [NC]
    RewriteCond %{HTTP_REFERER} !^http://www.mysite.com/.*$ [NC]
    RewriteCond %{HTTP_REFERER} !^http://www.mysite.com$ [NC]
    RewriteRule .*\.(jpg|jpeg|gif|png|bmp|wmv|css|js)$ - [F,NC]

  4. #4
    Hmm,

    Just curious have you tried removing the niftyplayer.swf\?file=.* from your RewriteCond and see if your player can play the file? You probably have, but I thought I would ask. *S*
    CIRRACORE
    http://www.colocube.com
    Enterprise and Private Cloud Services, Dedicated Servers, Fully Managed Servers, Colocation Rack and Cage Space, Tier 1 Bandwidth
    sales@cirracore.com

  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
    Hey I just found a hotlink code generator if you want to try figuring it out with that: http://www.htmlbasix.com/disablehotlinking.shtml

    Good luck, sorry I couldn't be more help.
    CIRRACORE
    http://www.colocube.com
    Enterprise and Private Cloud Services, Dedicated Servers, Fully Managed Servers, Colocation Rack and Cage Space, Tier 1 Bandwidth
    sales@cirracore.com

  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
    Location
    /root
    Posts
    23,991
    Moved > Technical & Security Issues.

    Specially 4 U
    Reseller Hosting: Boost Your Websites | Fully Managed KVM VPS: 3.20 - 5.00 Ghz, Pure Dedicated Power
    JoneSolutions.Com is on the net 24/7 providing stable and reliable web hosting solutions, server management and services since 2001
    Debian|Ubuntu|cPanel|DirectAdmin|Enhance|Webuzo|Acronis|Estela|BitNinja|Nginx

  9. #9
    LOL I don't mind helping if I can. *S*

    Didn't think about the flash players not providing a referrer.

    Good luck.
    CIRRACORE
    http://www.colocube.com
    Enterprise and Private Cloud Services, Dedicated Servers, Fully Managed Servers, Colocation Rack and Cage Space, Tier 1 Bandwidth
    sales@cirracore.com

  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
  •