1. Assume that the host domain name of the linked image is: www.test.com
2, modify the httpd.conf
Setenvifnocase Referer "^http://www.test.com/" local_ref=1
Order Allow,deny
Allow from Env=local_ref
This simple application can not only solve the picture hotlinking problem, a little modification can also prevent any file hotlinking download problem.
Using the above method when the image from a non-specified host link, the picture will not be displayed, if you want to display a "no hotlinking" picture, we can use mod_rewrite to achieve.
First, when installing Apache, add the--enable-rewrite parameter to load the Mod_rewrite module.
Assuming that the "Prohibit hotlinking" picture is abc.gif, we can configure this in httpd.conf:
Rewriteengine on
Rewritecond%{http_referer}!^$
Rewritecond%{http_referer}!^http://(www.)? test.com/.*$ [NC]
Rewriterule. (gif|jpg) $ http://www.test.com/abc.gif [r,l]
When the host's picture is hotlinking, only then will see abc.gif this "prohibits hotlinking" the picture!
A block of anti-theft PHP code
$ADMIN [Defaulturl] = "http://www.163.com/404.htm";//Address returned by hotlinking
$okaysites = Array ("http://www.163.com/", "http://163.com"); White List
$ADMIN [Url_1] = "http://www.163.com/download/";//Download Location 1
$ADMIN [url_2] = "";//download location 2, etc.
$reffer = $HTTP _referer;
if ($reffer) {
$yes = 0;
while (list ($domain, $subarray) = each ($okaysites)) {
if (Ereg ($subarray, "$reffer")) {
$yes = 1;
}
}
$theu = "url". " _"." $site ";
if ($ADMIN [$theu] and $yes = = 1) {
Header ("Location: $ADMIN [$theu]/$file");
} else {
Header ("Location: $ADMIN [Defaulturl]");
}
} else {
Header ("Location: $ADMIN [Defaulturl]");
}
?>
How to use: Save the above code as dao4.php
http://www.bkjia.com/PHPjc/486630.html www.bkjia.com true http://www.bkjia.com/PHPjc/486630.html techarticle 1, assume that the host domain name of the connection picture is: www.test.com 2, modify httpd.conf setenvifnocase Referer "^http://www.test.com/" local_ref=1 FilesMatch ". (gif|jpg) "Order allow,de ...