.htaccess to block direct access to files

  • Thread starter Thread starter THT
  • Start date Start date

THT

THT

Associate
Joined
10 Mar 2004
Posts
998
I want to stop people directly downloading a video from my site.
However, I want it still to be playable from within the HTML5 video player.

I thought I could do this with .htaccess to ensure the referer was from my site, so I did this:

Code:
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^https://www\.mysite\.com [NC]
RewriteRule \.(m4v)$ - [F,NC,L]

Why isnt this working?
 
Try this:

Code:
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?mysite.com [NC]
RewriteRule \.(m4v)$ - [F,NC,L]
 
Thats not what i want to do though?

Thats allowing a blank referrer which is exactly what I am trying to avoid!
 
Ok, I've reread your OP and realised I got the wrong end of the stick. You don't need hotlink protection which is what I originally posted. This is what you need:

Code:
<Files ~ "\.(m4v)$">
Order deny,allow
Deny from all
Allow from <your site>
</Files>
 
Back
Top Bottom