Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用.htaccess限制对文件的直接访问_.htaccess_Security_File Access_Restrictions - Fatal编程技术网

使用.htaccess限制对文件的直接访问

使用.htaccess限制对文件的直接访问,.htaccess,security,file-access,restrictions,.htaccess,Security,File Access,Restrictions,我的文件夹里有视频文件。我想限制用户直接访问它们。我有权这样做 RewriteEngine on RewriteCond %{HTTP_REFERER} !^http://(www\.)?localhost [NC] RewriteCond %{HTTP_REFERER} !^http://(www\.)?localhost.*$ [NC] RewriteRule \.(mp4|flv)$ - [F] 想法: 这将允许浏览器在第页请求时访问我的视频。但它将拒绝从url直接访问 实际答复:

我的文件夹里有视频文件。我想限制用户直接访问它们。我有权这样做

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

这将允许浏览器在第页请求时访问我的视频。但它将拒绝从url直接访问

实际答复:

它对铬的作用很好。但在所有其他浏览器中,firefox、opera、midori都没有发现错误。问题是什么?请提供任何帮助。

尝试以下规则:

RewriteEngine on

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

为什么这能解决OP的问题?不能说100%有把握,但各种浏览器扩展可以自定义或从服务器上删除%{HTTP\u REFERER}检查从Firefox、opera等收到的HTTP\u REFERER实际是什么。