In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >
Share
Shulou(Shulou.com)06/01 Report--
Summary of Apache hotlink protection
The first implementation of Apache hotlink protection can be implemented with rewrite.
one。 Encounter picture theft chain
Domestic website theft has become a trend, the most unfortunate is our kind of use of paid host traffic restrictions on the individual. There is no choice but to add a simple anti-hotlink (Anti-Leech) measure. My server is Apache, so it's easy to deal with hotlink protection. Welcome to my forum, memory fragment www.debris.cn, I hope you can give us more guidance!
two。 Use rewrite technology to implement Apache hotlink protection (jump to the specified page after rejection)
The first implementation of Apache hotlink protection can be implemented with rewrite. First of all, make sure that the rewrite module of Apache is available: if you can control the Apache httpd.conf file, open httpd.conf and make sure you have this line of configuration:
The code is as follows:
LoadModule rewrite_module modules/mod_rewrite.so
Then, where you find the configuration for your website, add the following code:
The code is as follows:
ServerName debris.cn
# hotlink protection configuration
RewriteEngine On
RewriteCond% {HTTP_REFERER}! ^ http://debris.cn/.*$ [NC]
RewriteCond% {HTTP_REFERER}! ^ http://debris.cn$ [NC]
RewriteCond% {HTTP_REFERER}! ^ http://www.debris.cn/.*$ [NC]
RewriteCond% {HTTP_REFERER}! ^ http://www.debris.cn$ [NC]
RewriteRule. *\. (gif | jpg | swf) $http://www.debris.cn/about/nolink.png [RMagneNC]
Description of hotlink protection configuration:
The red part: indicates your trust site. For my site, set to http://www.debris.cn and http://debris.cn
Green: the extension of the file to be protected (to | separate). Files with these extensions must be referenced by a red URL before they can be accessed.
The blue part: the redirected page after the hotlink. To output warning messages, this picture should be as small as possible. For simple reasons, in my green font section, there is no .png image in the image extension I want to protect, while the warning picture is .png.
Then restart the apache server.
Some users are using virtual hosts and cannot modify httpd.conf files or restart the server without control of the server. Then make sure that your virtual host supports .htaccess, write the above configuration to the .htaccess file, and put it in the root directory or the directory where the image is located:
The code is as follows:
The contents of the .htaccess file:
# hotlink protection configuration
RewriteEngine On
RewriteCond% {HTTP_REFERER}! ^ http://debris.cn/.*$ [NC]
RewriteCond% {HTTP_REFERER}! ^ http://debris.cn[NC]
RewriteCond% {HTTP_REFERER}! ^ http://www.debris.cn*$ [NC]
RewriteCond% {HTTP_REFERER}! ^ http://www.debris.cn$ [NC]
RewriteRule. *\. (gif | jpg | swf) $http://www.debris.cn/about/nolink.png [RMagneNC]
Note:
1. The configuration in the httpd.conf file is read once when apache is started, so it is very efficient.
2. The configuration in the htaccess file needs to be read and analyzed every time it is accessed, so it is very inefficient.
three。 Use SetEnvIfNoCase and access technology to achieve Apache hotlink protection (direct rejection)
Another way is to use SetEnvIfNoCase and access. The specific code is as follows:
The code is as follows:
SetEnvIfNoCase Referer "^ http://debris.cn"local_ref=1
SetEnvIfNoCase Referer "^ http://www.debris.cn" local_ref=1
Order Allow,Deny
Allow from env=local_ref
Put the above code into the httpd.conf or .htaccess file mentioned earlier.
four。 Technical summary of Apache hotlink protection
By judging the value of the referer variable and judging whether the reference of the picture or resource is legal, only the referer within the set range can access the specified resource, thus achieving the purpose of hotlink protection (Anti-Leech). It should be pointed out that not all user agents (browsers) set the referer variable, and some can modify referer manually, that is, referer can be forged. What this article talks about is only a simple means of protection. Of course, it is enough to deal with the general theft chain.
Welcome to visit the memory fragment www.debris.cn to find your memory in the fragments!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 208
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.