Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize the hotlink protection technology of Apache

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces "how to realize the technology of hotlink protection of Apache". In the daily operation, I believe that many people have doubts about how to realize the technology of hotlink protection of Apache. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubts of "how to realize the technology of hotlink protection of Apache". Next, please follow the editor to study!

The implementation method 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 copy 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 copy code is as follows:

ServerName jb51.net

# hotlink protection configuration

RewriteEngine On

RewriteCond% {HTTP_REFERER}! ^ http://jb51.net/.*$ [NC]

RewriteCond% {HTTP_REFERER}! ^ http://jb51.net$ [NC]

RewriteCond% {HTTP_REFERER}! ^ / / www.iis7.com/.*$ [NC]

RewriteCond% {HTTP_REFERER}! ^ / / www.iis7.com$ [NC]

RewriteRule. *\. (gif | jpg | swf) $/ / www.iis7.com/about/nolink.png [RMagneNC]

Hotlink protection configuration description: the red part: indicates their own trust site. For my site, set to http://www.xiaohui.com and http://xiaohui.com

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 example, my warning picture is / 2018img/2018/09/15143940.png. 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. (there are no other pictures of .png in my site)

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 http://www.bbqmw.net/ file, and put it in the root directory or the directory where the image is located:

The copy code is as follows:

The contents of the .htaccess file:

# hotlink protection configuration

RewriteEngine On

RewriteCond% {HTTP_REFERER}! ^ http://jb51.net/.*$ [NC]

RewriteCond% {HTTP_REFERER}! ^ http://jb51.net$ [NC]

RewriteCond% {HTTP_REFERER}! ^ / / www.iis7.com/.*$ [NC]

RewriteCond% {HTTP_REFERER}! ^ / / www.iis7.com$ [NC]

RewriteRule. *\. (gif | jpg | swf) $/ / www.iis7.com/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.

At this point, the study on "how to realize the technology of hotlink protection in Apache" is over. I hope to be able to solve everyone's doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

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: 0

*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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report