开发者

How can I use IIS URL Rewrite to prevent people from linking or leeching images on a website?

I came across the features of IIS and it notes that I ca开发者_Go百科n prevent inline linking or leeching. How can I implement such a rule?


You will need to use URL rewrite to point to a resource within a web application that will be able to identify the refferer before displaying the resource to the client which called the application.

IE, rewrite the following /images/myPhoto.JPG to /getResource.PHP?resource=%2Fimages%2FmyPhoto.JPG

Then inside getResource.PHP forgive me if this isn't quite right, my php is a little sketchy, but you get the idea

header('Content-Type: image/jpeg');
if(isset($_SERVER['HTTP_REFERER'])) {
    if( /*test that it fits your criteria*/ true ) {
        $imagepath= $_GET['resource'];
    } else {
        $imagepath= "/images/stopLeaching.JPG";
    }
} else {
    $imagepath= $_GET['resource'];
}

$image=imagecreatefromjpeg($imagepath);

imagejpeg($image);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜