Configuration of. htaccess anti-Leech in Apache

Source: Internet
Author: User

If apache does not support. htaccess, perform the following operations:

Open the httpd. conf file in a text editor and find

The code is as follows: Copy code


Options FollowSymLinks
AllowOverride None

Changed:

Options FollowSymLinks
AllowOverride All

 

However, I did not find Options FollowSymLinks or other things in my httpd. conf file. I have

The code is as follows: Copy code
 
Options FollowSymLinks
AllowOverride All

 
Manually add it to the httpd. conf file and restart the Apache server.


Now let's configure anti-Leech. Create a. htaccess file in the root directory of your website and add the following code to the page:

The code is as follows: Copy code


RewriteEngine On
RewriteCond % {HTTP_REFERER }! ^ $ [NC]
RewriteCond % {HTTP_REFERER }! Phpddt.com [NC]
RewriteCond % {HTTP_REFERER }! Google.com [NC]
RewriteCond % {HTTP_REFERER }! Baidu.com.com [NC]
RewriteCond % {HTTP_REFERER }! Feedburner.com [NC]
RewriteCond % {HTTP_REFERER }! Feedsky.com [NC]
RewriteRule. *. (rar | zip) $ http://www.111cn.net/[R, NC, L]

The above code is also easy to understand:

The code is as follows: Copy code
RewriteCond % {HTTP_REFERER }! ^ $ [NC]

An empty source is allowed, that is, if the user's browser manually belongs to the source, files can be accessed.

The code is as follows: Copy code
RewriteCond % {HTTP_REFERER }! Phpddt.com [NC]

Allow access to the site itself. Similarly, access to Baidu, Google, and some subscription sources will be allowed later.

The code is as follows: Copy code
RewriteRule. *. (rar | zip) $ http://www.111cn.net/[R, NC, L]

Here, you can set the anti-Leech protection type. If you can jump to the homepage of a website, there is no anti-Leech protection for images on this site. If you do an anti-Leech protection for images, you can set an alternative image for the leeching:

The code is as follows: Copy code
RewriteRule. *. (gif | jpg | png) $ http:/www.111cn.net/logo.png [R, NC, L]

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.