You can design anti-leech protection for your host, including image anti-leech protection and download anti-leech protection, for example:
1. Use. htaccess to set anti-leech
Copy codeThe Code is as follows: RewriteEngine on
RewriteCond % {HTTP_REFERER }! ^ $
RewriteCond % {HTTP_REFERER }! ^ Http: // (www \.)? Jb51.net/.*$ [NC]
RewriteRule \. (gif | jpg) $ http://www.jb51.net/image.gif [R, L]
2. Set anti-leech protection for nginx
Copy codeThe Code is as follows: location ~ * \. (Gif | jpg | png | swf | flv) $ {
Valid_referers none blocked jb51.net;
If ($ invalid_referer ){
Rewrite ^/http://jb51.net/234_s.gif;
# Return 404;
}
}
But how to crack anti-leech? Generally, anti-leech is used to determine whether the origin is your own domain name. We can use the file_get_contents Method built in php to request this image (of course, other backend languages also have similar methods), such:
Copy codeThe Code is as follows: // getImg. php? Url = Target Image connection
<? Php
Header ('content-type: image/jpeg ');
Echo file_get_contents (isset ($ _ GET ["url"])? $ _ GET ["url"]: 'http: // static.jb51.net/images/v1/loading-16-16.gif ');
?>
Example:
1. Directly attach anti-leech images: (unauthorized images on the site are displayed blank)
2. Read images through php: