Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/symfony/6.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_Wildcard_Hotlinking - Fatal编程技术网

如何在.htaccess中排除热链接阻止的某些文件名

如何在.htaccess中排除热链接阻止的某些文件名,.htaccess,wildcard,hotlinking,.htaccess,Wildcard,Hotlinking,我的照片文件夹的.htaccess中当前有以下内容 RewriteEngine on RewriteCond %{HTTP_REFERER} !^$ RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?siteabc.com [NC] RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?sitexyz.com [NC] RewriteRule \.(jpg|jpeg|png|gif)$ http://ex

我的照片文件夹的.htaccess中当前有以下内容

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?siteabc.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?sitexyz.com [NC]
RewriteRule \.(jpg|jpeg|png|gif)$ http://example.com/images/bandwidth.png [NC,R,L]
这将阻止所有不允许的域热链接我们的照片文件,并在其位置显示

然而,我想做的是允许网站能够热链接我们的缩略图。缩略图具有这种文件名格式

filenameabc_100_cw100_ch100_thumb.jpg
filenameabc_100_cw100_ch100_thumb.png
filenamexyz123_100_cw100_ch100_thumb.png
例如文件名都以_thumb.ext结尾

所以我想做的是修改上面的.htaccess来全局阻止所有的访问,除了以thumb结尾的文件名如*\u thumb.jpg或*\u thumb.png

我一点也不知道如何写这样一条规则


如果有人有任何想法,我将不胜感激。

修改问题中的规则集:

你可以试试这个:

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?siteabc.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?sitexyz.com [NC]
# Add this other exception
RewriteCond %{REQUEST_URI}  !_thumb\.  [NC]
RewriteRule \.(jpg|jpeg|png|gif)$ http://example.com/images/bandwidth.png [NC,R,L]

修改问题中的规则集:

你可以试试这个:

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?siteabc.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?sitexyz.com [NC]
# Add this other exception
RewriteCond %{REQUEST_URI}  !_thumb\.  [NC]
RewriteRule \.(jpg|jpeg|png|gif)$ http://example.com/images/bandwidth.png [NC,R,L]