First, why use the anti-theft chain?

What is thievery?

Under normal circumstances, the direct links to other sites if virtual host of web pages, is can improve the visibility of websites and visits, is welcomed by ICP content providers or webmaster, however, if the other is secretly directly link to your site in music, movies, pictures, download the zip file and other class resources, let users free to see your movies, Not only will not improve the popularity of your site, but also let your site to generate a lot of meaningless traffic, if there is a large number of this link in a server, server speed will decline.

From the point of view of ICP content provider or webmaster, work hard to make the content, be used secretly by others, affirmation in the heart is not good, obviously, this kind of chain is the behavior of infringement of intellectual property rights. For downloadable sites that charge a fee, this means someone can enjoy your service without paying! To make matters worse, many virtual hosting providers use the “IIS connection count” to allocate server resources to each virtual host. When a link breach occurs, it is obvious that meaningless “IIS connections” are generated. Enable the anti-linkedguard service component. This is set on the server. Users do not need to perform any operations

Two, Ngnix how to use anti-theft?

1. Find our Ngnix profilengnix.confThen add the following code:

How to find ngnix under Linux configuration files ps – ef | grep nginx

The location ~ * \. (GIF | JPG | PNG | SWF | FLV) ${# need hotlinking prevention resource file type valid_referers *. Lishuo.net, lishuo.net; If ($invalid_referer) {if ($invalid_referer) {if ($invalid_referer) {if ($invalid_referer) { Unless there is a separate image server that supports #rewrite ^/ https://dss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=1201024306, & FM = 26 & gp = 0. 578860947 JPG. Return 403; return 403; Return 403 error codeCopy the code

Then remember to restart our Ngnix service

Find our ngnix path and then use the command: / usr/local/nginx/sbin/nginx -s reload

Three, How does Apache use anti-thievery

Take ThinkPHP5.0 as an example, we write the anti-theft configuration information in the public. Htaccess file

RewriteEngine On RewriteCond %{HTTP_REFERER} ! ^$ [NC] RewriteCond %{HTTP_REFERER} ! # month.com (NC) this is the domain name or IP address can be hotlinking RewriteRule. * \. (JPG | PNG | jpgrar | zip) $ https://dss1.bdstatic.com/70cFuXSh_Q1YnxGkpoWK1HF6hhy/it/u=3566088443-3713209594 & FM = 26 & gp = 0. JPG [R, NC, L] If the domain name or IP address of the link does not match, this step is takenCopy the code

Four, we test whether the anti-theft chain is effective

For example, I load an image in an HTML file of a local project (url is “month.com”)

Local project example, random find a static page, configure the static page domain name to day10.com, and then change the page to introduce my month.com project under the picture

At this point we go to this page under this domain name and make sure to force refresh Ctrl+ F5

If it is not the domain name or IP address that we can sneak, then the access effect is the picture that we redirect, then anti-sneak is in effect

Five, the END

Articles continue to update, you can search a wechat “ke” for the first time to read, reply [source code] I prepared small program source code and website source code.