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
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 Sep 26 '09 at 1:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.