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"