4

I have this in my htaccess at the public_html folder of my file server:

RewriteEngine On
RewriteBase /
ReWriteCond %{REQUEST_URI} ^/files/*
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?mysite.net/.*$ [NC]
RewriteRule \.(gif|png|jpg|jar|sis|mp3|thm)$ - [F]

And I have lots of folders and files inside the mysite.net/files dir, which I want to prevent from being direct-downloaded from sites other than mysite.net. However the above rules don't seem to work despite I know that .htaccess file is enabled. In some cases it only blocks the images but no the files. Please tell me what's wrong with that script, or if I can use any other directive to prevent external sites from leeching my files constantly. Thanks

0

1 Answer 1

2

Does it help if you add ".*"?

RewriteRule .*\.(gif|png|jpg|jar|sis|mp3|thm)$ - [F]

Also, your line:

ReWriteCond %{REQUEST_URI} ^/files/*

means (at the end) "a slash zero or more times". You might try:

ReWriteCond %{REQUEST_URI} ^/files/.*

which means "a slash then any character zero or more times".

Edit: Some of your files may be named with uppercase extensions. You might try:

RewriteRule .*\.(gif|png|jpg|jar|sis|mp3|thm)$ - [F,NC]
1
  • No, that didn't solve the problem, it seems there's something else wrong in that config. :(
    – andreszs
    Commented Sep 26, 2009 at 1:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .