Implementation of IIS image anti-leech Based on ISAPI rewrite Software

Source: Internet
Author: User

The following operations may be objectionable to users. If a visitor wants to save an image on your page, what is the user experience.

Implementation steps:
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: CopyCode The Code is as follows: rewritecond HOST: ^ (. +) $
Rewritecond Referer: ^ (?! Http: // \ 1. *). * $
Rewritecond Referer: ^ (?! Http: //. * .baidu.com |. * .google.com |. * googlebot.com |. * .jb51.net). *). * $
Rewriterule ^ (?! (/Logo.gif |/2_files/logo_tg.gif )).*.(? : GIF | JPG | JPEG | PNG) $/block.gif [I, O, N]

Explanation:
A. in the third row of the above rule, www.jb51.net is your website domain name. Please modify the domain name according to the actual situation. The Baidu.com and Google.com are in order not to prevent search engine spider from capturing images.
B. In the fourth line,/logo.gif and 2_fies/logo_tg.gif serve as the address of your logo image. The purpose is to allow other people to use your logo through links. If you do not need it, remove "(?! (/Logo.gif |/2_files/logo_tg.gif ))". You can modify the subsequent GIF files as needed.
In addition, you do not need to restart IIS to modify the rule. You only need to modify the httpd. ini configuration file.

The following are related to other netizens:Article

Isapi_rewrite can be used to implement pseudo-static paths similar to Apache. We can also implement anti-leech protection using its refer check function. The software can be. I will not elaborate on the Installation Steps. For more information, see httpd. ini settings.
First, you must ensure that httpd. INI has the writable permission. After setting the isapi_rewrite installation folder everyone to have the modifiable permission, remove the read-only attribute of the file.
The default settings of httpd. ini are as follows:
Rewritecond HOST: (. +)
Rewritecond Referer :(?! Http: // \ 1 .*).*
Add a sentence to it.
Rewriterule .*\\.(? : GIF | JPG | PNG | exe | RAR | zip)/block.gif [I, O]
You can implement anti-leech protection for GIF/jpg/PNG/EXE/RAR/ZIP files. The anti-leech page displays/block.gif. Block.gif is a small image file. we can add the copyright logo and anti-leech statement of our website on it.
If you follow the settings above, no website except this site can use the images here. What if you want to allow some exceptional websites such as Google, Baidu and other non-profit websites to reference the images? We can use the following regular expression to implement
Rewritecond Referer :(?! Http ://(? : Www \. liehuo \. Net | www \. Google \. com | www \. Baidu \. com). +
If you want to allow all Google sub-sites and Baidu sub-sites, such as images.baidu.com and images.google.com, perform the following settings:
Rewritecond Referer :(?! Http ://(? : * \. Liehuo \. Net | * \. Google \. com | * \. Baidu \. com). +
So far, a quite effective anti-leech system has come out, but there is a problem with the above settings. If a viewer browses the leeching page and then visits the site page, the cache of the leeching image will affect the normal display of the image. Set
Rewriterule .*\\.(? : GIF | JPG | PNG | exe | RAR | zip)/block.gif [I, O]
Change
Rewriterule .*\\.(? : GIF | JPG | PNG | exe | RAR | zip)/block.gif [I, O, N]
. Parameter n indicates re-reading from the site request file rather than from the local cache.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.