我在我的.htaccess文件中有代码,以防止我的网站上的图像热链接。我需要的是使它允许热链接的图像,如果他们在URL的末尾有一些参数,例如:
此图像应被阻止:
https://my-site.com/my-images/some-image-file-name.jpg但是,如果同一图像末尾有参数,则允许热链接,例如:
https://my-site.com/my-images/some-image-file-name.jpg?allow_hot_linking为什么我需要这样的东西?例如,如果图像在html电子邮件中发送,它将不会显示,但如果我可以制定一些.htaccess规则,允许使用参数热链接图像,我将简单地将该参数放在制作html电子邮件时图像的img源标签的末尾,它将在电子邮件打开时出现。
这是我的.htaccess代码
RewriteCond %{HTTP_REFERER} !^http(s)?://(www.)?my-site.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www.)?nnn.nnn.nn.nnn [NC]
##Allow search engines
RewriteCond %{HTTP_USER_AGENT} !Googlebot-Image [NC]
.
.
.
##Allow blank referrers
RewriteCond %{HTTP_REFERER} !^$
## Redirect to hotlink image
RewriteRule ^my-images/(.*).(jpeg|jpg|bmp)$ https://my-site.com/no-hotlinking.html [NC,R,L]
## End - prevent image hotlinking发布于 2020-07-04 04:25:13
喜欢这个解决方案,正是我正在寻找的,以允许从电子邮件的链接,而不是从空白推荐人。
RewriteCond %{QUERY_STRING} !^ahl$ [NC]就像做梦一样。
https://stackoverflow.com/questions/51947212
复制相似问题