Application of advanced anti-hotlinking site

Now do site, will encounter problems hotlinking, hotlinking including pictures, music or video files (such as mp3, Flash, etc.) hotlinking. I believe many of my friends have encountered the situation within the Web site files in particular, images are hotlinking . Here we are on this issue is to analyze the principles and solutions.

 

  The so-called hotlinking: refers to other sites link directly to files on your website, rather than placing it on your own server, in general, hotlinking target mostly the more bandwidth-consuming bulky files such as pictures, video, etc. , in a sense, which in fact it resulted in allowing you to pay for traffic: not only your server bandwidth is occupied without anything in return, and that tends to affect the access speed of your site on a large program

How Daolian: just use basic html knowledge, such as using a nested img pictures in the article published, href link to a file downloads.

  Anti-hotlinking of principle and method: Referer head judge is not his own domain name, such as after a while I want to say apache ban hotlinking of images to achieve, on the use of this method.

  Here we are in the picture as an example to illustrate this.

  To achieve the purpose: we want to achieve is not only shield / disable hotlinking access to off-site, the request will be forwarded to Daolian own site and let readers know who the real publisher (Image source site)

  Set the rul apache rewrite functions such as adding the following settings to .htaccess, to achieve this function. Prohibits pictures hotlinking.

  RewriteEngineon

  Open url rewrite

  RewriteCond%REQUEST_URI!^/allow/.*$

  Excluded url. This is quite important because when these will filter back referer filtering so you can open the "hotlinking", so as to let the user correct the error display site.

  RewriteCond%REQUEST_FILENAME\.(gifjpegpngjpg)$NC

  Above to determine whether the image files: You can also set more file types according to their needs. And the like can also be exe

  RewriteCond%HTTP_REFERER!^$

  Displayed above this line is intended to allow empty "HTTP_REFERER" access, which allows the user to enter the picture address directly into the browser address bar image files. Suggested that if forced must have "HTTP_REFERER" to access may pose some problems, such as directly enter the address in the address bar url

  RewriteCond%HTTP_REFERER!chinaitlab\.comNC

  RewriteCond%HTTP_REFERER!google\.comNC

  RewriteCond%HTTP_REFERER!baidu\.comNC

  HTTP settings allow access to the source, including the site itself, Google, Baidu, and so on.

  RewriteRule(.*)/allow/error.gifR=301,NC,L

  The visit does not satisfy the conditions referer redirected to error.gif. Have not found error.gif located Allow "hotlinking" directories allow, it should rather pay attention, otherwise, warning messages and pictures will not be displayed on other sites.

  As above, to achieve the functionality we want. Not only shield / disable non-hotlinking to access the website, Daolian request will be forwarded to their site and let readers know who the real publisher (Image source site)

  Anti-hotlinking setting other types of files

  If there are other similar larger than the cost of bandwidth files such as flash, mp3 hotlinking other sites, can also take the above strategy, for example, the Flash file that you can set up similar to the following on your website:

  RewriteCond%REQUEST_URI^/allow

  RewriteCond%REQUEST_FILENAME\.swf$NC

  RewriteCond%HTTP_REFERER!^$

  RewriteCond%HTTP_REFERER!chinaitlab\.comNC

  RewriteRule(.*)/allow/error.swfR=301,NC,L

  Of course, there are flash file requires prior declaration copyright information "error.swf". Others such as mp3 files, compressed files (zip or rar) hotlinking settings and the same.

  Of course, more likely to speak with a master referer false, that we have more advanced methods, such as User-Agent, etc. plus other head judge, such as Cookie and other records to determine when to set up than ever IP, access control page session, to determine whether other methods came when accessing pictures.

Guess you like

Origin www.cnblogs.com/56843268qqq/p/12354149.html