Apache anti-theft chain (Picture/file) a variety of methods

Source: Internet
Author: User
Tags rar

If you have a server of your own, make the following modifications to the./conf/httpd.conf file
Find: #LoadModule rewrite_module modules/mod_rewrite.so
Take the front # off
Find one allowoverride None to allowoverride all
Restart the Apache2 server
then do a. htaccess file, and its. htaccess file content is

  code is as follows copy code
rewriteengine On
Rewritecond%{http_referer}!^[url]http://test.com.ru/.[ /url]*$ [NC]
Rewritecond%{http_referer}!^[url]http://test.com.ru$[/url] [NC]
Rewritecond%{http_referer}!^[ url]http://www.test.com.ru/. [/url]*$ [NC]
Rewritecond%{http_referer}!^[url]http://www.test.com.ru$[/url] [NC]
Rewriterule. *. ( Jpg|jpeg|gif|png|bmp|rar|zip|exe) $
[url=http://down.test.com.ru/err.html]http://down.test.com.ru/err.html[/ URL]
[R,NC]

where all the colored places are changed to yours:
Red: That is, you provide the address of the download page, that is, only through this address can download the dongdong you provided.
Blue: is to protect file extensions (separated by |), meaning that files with these extensions are accessible only through red addresses.
Green: Redirects to a green address if the blue files are not accessed through a red address, which is the file name extension.
Then how to use the. htaccess file to implement the Anti-Theft chain.
First you have to build two directories in space (with your directory name, of course), one for the web and the other for Down,
The web is used to put down the load page (or download the program), down of course is to let you provide the stuff,
Change the red part of the. htaccess file to http://your domain/web. Blue part
Change to the extension of the file you want to protect. Change the green section to http://your domain/web. Save after change


Htaccess anti-theft chain is simple and quick.

First build A. htaccess file (the Linux system is generally Apache server), write the following code, upload to the site root directory:

The code is as follows Copy Code

Rewriteengine on

Rewritecond%{http_referer}!^$ [NC]

Rewritecond%{http_referer}!www.111cn.net [NC]

Rewritecond%{http_referer}!google.com [NC]

Rewritecond%{http_referer}!baidu.com [NC]

Rewritecond%{http_referer}!www.hihi123.com [NC]

Rewriterule. *. (gif|jpg|png) $ http://www.111cn.net/nopic.gif [r,nc,l]

Description

The above is to my website www.111cn.net as an example, set up to allow access to the HTTP source, including our site itself, google.com, baidu.com these search engine sites, easy to include, you can add more sites, copy more than one line of modification on the line.

The last line of code is an anti-theft chain extension, add their own changes; http://www.111cn.net

Position generally in/usr/local/apache/conf/httpd.conf
Or the/usr/local/apache2/conf/extra/httpd-vhost.conf of Apache 2.2.
Add to

The code is as follows Copy Code
Setenvifnocase Referer "^http://www.ccvita.com" local_ref=1
Setenvifnocase Referer "^http://ccvita.com" local_ref=1
<filesmatch ". (txt|doc|mp3|zip|rar|jpg|gif) ">
Order Allow,deny
Allow from Env=local_ref
</filesmatch>

Where the bold is your URL, if there are multiple, add more lines
Italic is that you need the file suffix of the chain, the middle used to separate


Also a kind of writing, is to use regular, this kind of writing in each version of Apache more general.
The wording is

The code is as follows Copy Code
Setenvifnocase Referer "^<strong>http://.*.yourdomin.com</strong>" local_ref=1 SetEnvIfNoCase Referer " <strong>.*.yourdomin.com</strong> "Local_ref=1
<filesmatch ". (txt|doc|mp3|zip|rar|jpg|gif) ">
Order Allow,deny
Allow from Env=local_ref
</filesmatch>

One of the bold parts is a little different, with regular writing, the symbol is escaping, because. itself has its own role in the regular.

said above is the use of Apache anti-theft chain, now that the Apache anti-theft chain to crack, said simple point Apache anti-theft chain is through the antecedents to determine whether the user is hotlinking, if you write the acquisition program, we can fully use the PHP Curl_ The two functions Curlopt_referer and curlopt_useragent in the SETOPT function simulate Referer and useragent.

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.