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 - Fatal编程技术网

.htaccess 图像热链接

.htaccess 图像热链接,.htaccess,.htaccess,我一直在寻找通过.htaccess阻止其他域下载图像的方法,到目前为止,这是我最喜欢的方法,但做了一些修改: RewriteCond %{HTTP_REFERER} !^$ RewriteCond %{HTTP_REFERER} !^http://(www\.)?mydomain\.com [NC] #RewriteCond %{HTTP_REFERER} !^http://(www\.)?otherdomain\.com [NC] RewriteRule \.(gif|jpe?g|js|css

我一直在寻找通过.htaccess阻止其他域下载图像的方法,到目前为止,这是我最喜欢的方法,但做了一些修改:

RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?mydomain\.com [NC]
#RewriteCond %{HTTP_REFERER} !^http://(www\.)?otherdomain\.com [NC]
RewriteRule \.(gif|jpe?g|js|css)$ - [F,NC,L]
好的一个和工程,但只有某些图像

有没有办法阻止对所有图像的访问

提前谢谢

更新:
我的所有图像文件都位于mydomain.com/Images

在这种情况下,您可能需要尝试:


我认为没有一个指令包含所有图像类型。当它们位于一个或多个目录中,阻止对目录的访问而不是对文件的访问时,这是可能的。为什么不试着在你的问题中为代码添加缺失的扩展名呢?谢谢你的回答。你是对的,我不应该试图阻止对每个文件的访问,而是阻止对它们所在目录的访问。我会更新答案的。太好了。谢谢@Felipe,我应该找个时间看看Apache文档。
RewriteCond expr "! %{HTTP_REFERER} -strmatch '*://%{HTTP_HOST}/*'"
RewriteRule ^/images - [F, NC]     # No need for L, it is implied when using F