Forum Moderators: phranque

Message Too Old, No Replies

.htaccess newb here...need some help

         

vice86

4:44 am on Nov 8, 2004 (gmt 0)



Hi there...first time poster here. Here's my dilemma.

I'm trying to block access to FILES and FOLDERS from hotlinking on my site. I got the FILE part down.

Here's what one .htaccess file I'm using to block a .zip file looks like which works in blocking this file from any site except the one set in my htaccess file...even copying and pasting wont let you copy it, as well as save as wont work:

RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://www.example.com/.*$ [NC]
RewriteRule .*\.zip$ - [F]

Now here's what I can't figure out...I have a folder on my server called "edpart1" taht contains about 400 mp3s that I don't want people to be able to hotlink. How do I set up an .htaccess file for it so only the site i put in can see it and no one else can? I tried this code and put it in the "edpart1" folder but it didnt work:

RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://www.example2.com/.*$ [NC]
RewriteRule .*\.mp3$ - [F]

That blocks it all...but it also blocks the link that I posted on example2.com. Any ideas what I'm doing wrong?

[edited by: jdMorgan at 1:50 pm (utc) on Nov. 8, 2004]
[edit reason] Removed specifics per TOS. [/edit]

jdMorgan

1:58 pm on Nov 8, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



vice86,

Welcome to WebmasterWorld!

Because you are linking to .mp3 files, it's likely that the link will be opened by a "media player" type application or plug-in. These programs typically do not provide a referrer with their requests. Therefore, the requests are blocked because a blank referrer won't match the required "example2" domain.

Blocking by referrer is a simple, but only partially-effective solution. Look into using cookies [google.com] and possibly sessions to control access to your resources.

Jim