Server anti-theft chain
Assuming the domain name is www.localhost.com
1.apache Configuration httpd.conf
" ^http://www.localhost.com/ " local_ref=1". ( gif|jpg)"> from env=</FilesMatch>
2.apache configuration. htaccess
Rewriteengine on Rewritecond%{http_referer}!^$ rewritecond%{http_referer}!^http://(www.)? Localhost.com/.*$ [NC] rewriterule. (gif|jpg) $ http://www.localhost.com/noAllowed.gif [r,l] # # # # #设置非指定域名下的防盗链图片展示
3.nginx settings/usr/local/nginx/conf/nginx.conf This file, match the following code in the server{} segment
Location ~. *\. (gif|jpg|jpeg|png|bmp|swf) ${ expires 30d; Valid_referers www.locahost.com;
if ($invalid _referer) {
return 403; #禁止访问
#rewrite ^ (. *) $403.jpg # # #设置防盗链提示图片
}}
45.php settings
<?php//get REFERER Browser open page without REFERER if (isset ($_server[' http_referer ')) { if (Strpos ($_server[') Http_referer '], "http://www.localhost.com/") ==0) { ...
Header ("location:403.php");//jump page to warning.php
} } else header ("location:403.php"); ? >
PHP and related server anti-theft chain