问题原文
原帖链接 · Ankit Jha · CC BY-SA 4.0
I'm being heavily spammed by image scraper sites. There are more than 150+ domains targeting my images & sending spammed links to my site. I just want to prevent hotlinking from them. I just want to block only those specific sites.
Is there any htaccess rule for preventing hotlinking in specific sites only and allow others which is not included in list?
社区高分解答
原帖链接 · closetnoc · CC BY-SA 4.0
Using https://www.htaccesstools.com/hotlink-protection/
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?example.com [NC]
RewriteRule \.(jpg|jpeg|png|gif)$ - [NC,F,L]
You may or may not need RewriteEngine on. The next line allows a blank referrer. You may need to examine your log files and may optionally remove this line.
The last two lines are the meat of the code. Change example.com to your domain name. As well, if you want to add or remove more image types, you can simply add them or remove them. Please not the | character is an or character. You need these in your list just as you see them. In this case, jpg or jpeg or png or gif.
You can certainly use the link above to do this for you.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
