anilCSE
anilCSE

Reputation: 2461

Restricting direct access to files using .htaccess

I have video files in a folder. And I want to restrict the users from directly accessing them. I have my .htaccess like this

RewriteEngine on 
RewriteCond %{HTTP_REFERER} !^http://(www\.)?localhost [NC] 
RewriteCond %{HTTP_REFERER} !^http://(www\.)?localhost.*$ [NC] 
RewriteRule \.(mp4|flv)$ - [F]

IDEA:

This will allow the browser to access my video when requested from page. But it will deny direct access from url.

Actual response:

Its working fine for Chrome. But in all other browsers (firefox, opera, midori) Its giving StreamNotFound error. What is the issue? Any help please.

Upvotes: 1

Views: 237

Answers (1)

anubhava
anubhava

Reputation: 785611

Try this rule:

RewriteEngine on

RewriteCond %{HTTP_REFERER} !^$ [NC] 
RewriteCond %{HTTP_REFERER} !^http://(www\.)?localhost [NC] 
RewriteRule \.(mp4|flv)$ - [NC,F]

Upvotes: 0

Related Questions