Print Page | Close Window

Remote Image Linking

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=3656
Printed Date: 30 March 2026 at 5:02am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Remote Image Linking
Posted By: b_bonnett
Subject: Remote Image Linking
Date Posted: 18 June 2003 at 9:41pm
Can anyone tell me how to prevent remote image / file linking on a Windows server? I have been able to find how to do it on a non-Windows server but that isn't much use to me .

Thanks in advance,
Blair

-------------
Webmaster, http://www.planegallery.net/ - The Plane Gallery
Greetings From Christchurch



Replies:
Posted By: Gullanian
Date Posted: 19 June 2003 at 3:10am
If you mean hotlinking, I dont think there is really any way you can, however in ASP theres a handy FSO (file system object).  I think the best way of stopping hotlinking is to store the image path in a database, use FSO to move all images to another folder with a random name daily, and then change the database value


Posted By: MorningZ
Date Posted: 19 June 2003 at 8:02am

the FSO method would be a lot of overhead

and easy asp way would be like:

<%
'ShowImage.asp
RequestedImage = Request.QueryString("file")
ThisReferer = Request.ServerVariables("HTTP_REFERER")
MyDomain = "mydomain.com"  '<<== whatever your domain is, leave out the "www"

if Instr( ThisReferer, MyDomain ) then
       Response.Redirect(RequestedImage)
else
       Response.Redirect("/images/accessdenied.jpg")
end if
%>


So you would just code in:
<img src="ShowImage.asp?file=/images/someimage.jpg"/>

let me note that this is super slimmed down, but hopefully you get the idea



-------------
Contribute to the working anarchy we fondly call the Internet


Posted By: Mart
Date Posted: 19 June 2003 at 1:04pm
The only problem with that is it tells you the original image (ShowImage.asp?file=/images/someimage.jpg) in the querystring...


Posted By: MorningZ
Date Posted: 19 June 2003 at 2:01pm

lemme note again that i never posted that as "working/final" code, just a quick 5 mins of my time to display what can be done

with that said, you could do:

<%
'ShowImage.asp
RequestedImage = Request.QueryString("file")
ThisReferer = Request.ServerVariables("HTTP_REFERER")
MyDomain = "mydomain.com"  '<<== whatever your domain is, leave out the "www"
MyImageDirectory = "/thisdirectory/"

if Instr( ThisReferer, MyDomain ) then
       Response.Redirect(MyImageDirectory & RequestedImage)
else
       Response.Redirect("/images/accessdenied.jpg")
end if
%>

 

Now:
<img src="ShowImage.asp?file=someimage.jpg"/>

gives no idea what directory its in



-------------
Contribute to the working anarchy we fondly call the Internet


Posted By: Gullanian
Date Posted: 19 June 2003 at 2:08pm
Thanks morning Z, thats a great idea ive never thought of that before!


Posted By: the boss
Date Posted: 03 July 2003 at 1:00am

here is something cool too

http://www.javascriptkit.com/howto/htaccess10.shtml - http://www.javascriptkit.com/howto/htaccess10.shtml




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net