How to prevent the image of their own site is stolen by other sites, resulting in the loss of their own website traffic "Apache article"

Source: Internet
Author: User

The problem of the station picture being embezzled by other websites I think it's a bit difficult to solve the business logic code.

and Apache only needs a simple configuration to solve this problem.

Workaround:

1. Make sure your Apache is loaded with the Mod_setenvif module (Linux below: grep "mod_setenvif"/etc/httpd/conf*/*.conf check if there is LoadModule mod_ Setenvif this line of instructions loaded)

2. In your server root configuration parameters, add

<filesmatch "\. (jpg|jpeg|gif|png) $ ">    setenvifnocase Referer" http[s]?:/ /"Fill in your website domain name" "local_referer=1    Order allow,deny allow from    env=local_referer</filesmatch>

Please note that there is no comment code above

The contents of the <Directory></Directory> block code here are the parameter settings for the site's root directory, and the <FileMatch></FileMatch> The content in the code block is used to configure the corresponding file (the corresponding file here is the "\" in which the regular expression can be matched. (jpg|jpeg|gif|png) $ ") is the parameter that matches the picture name when using a regular form.

Simple parameter Solution

Setenvifnocase indicates that a variable is assigned a value when a parameter equals a value

Allow from Env=local_referer represents env=local_referer when a user is allowed to access the resource

"The content of this article is I learned from the second edition of Apache Cookbook"

How to prevent the image of their own site is stolen by other sites, resulting in the loss of their own website traffic "Apache 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.