If the website traffic is limited, anti-Leech protection is necessary for images. This not only reduces traffic waste, but also reduces the burden on servers. To enable the image anti-Leech function, add the following code to the htaccess file:
Rewriteengine on
Rewritecond % {http_referer }! ^ $
Rewritecond % {http_referer }! ^ Http: // (www .)? Allow1.com (/)?. * $ [Nc]
Rewritecond % {http_referer }! ^ Http: // (www .)? Allow2.com (/)?. * $ [Nc]
Rewriterule. *. (gif | jpg | jpeg | bmp | png) $ [r, nc, l]
In the above code, allow1.com and allow2.com are the domain names that allow access to website images, and baidu.com is the destination image address. The above also contains the suffix parameter of the image file, which can be changed by yourself. If you use the htaccess online builder to generate this code segment, you only need to fill in a few domain names that are allowed to access (without www or http), and then fill in the address of the image to be replaced.
Read oneIis anti-Leech
1. Download the free version of The isapi rewrite software provided by the famous www.helicontech.com (although the free version has some functional limitations, it is sufficient for anti-Leech protection ):
Http://www.isapirewrite.com/download/isapi_rwl_x86_0072.msi
2. Set the read and write permissions of the iis_wgp group in the software installation directory (important. If you do not set the permissions, your website will directly serve unavailable and cannot be accessed ).
Setting method:
If your installation directory is d: program filesheliconisapi_rewrite (the default installation directory is program filesheliconisapi_rewrite), right-click isapi_rewrite, choose "properties"> "security"> "add"> "advanced"> "search now". An iis_wgp item is found. Double-click "add" and click "OK. Select the group and click "full control" to grant the read and write permissions to the group.
3. install the software (iis will be restarted during the installation process), select the directory in which permissions are set in the previous step, and open internet information service in the control panel after installation, in the "open website properties" dialog box, there is an "isapi filter". Click "add" and enter a name that is easy to understand, click "browse" for "executable files" and select isapi_rewrite.dll in the installation directory of isapi_rewrite, and click OK. Restart iis.
4. Modify the httpd. Ini file in the installation directory (if the file is read-only, remove the file and modify it again)
Add:
Rewritecond host: ^ (. +) $
Rewritecond referer: ^ (?! Http: //. *). * $
Rewritecond referer: ^ (?! Http: //. * .baidu.com |. * .google.com |. * googlebot.com |. * .abc.net). *). * $
Rewriterule ^ (?! (/Logo.gif |/2_files/logo_tg.gif )).*.(? : Gif | jpg | jpeg | png) $/block.gif [I, o, n]