Forum Moderators: phranque

Message Too Old, No Replies

htacess for direct image link

prevent plain image display

         

santapaws

2:28 pm on Oct 27, 2011 (gmt 0)

10+ Year Member



is there anyway to prevent or redirect requests for just an image? That is when an image is linked to directly it displays in the browser with nothing to tell people about the website or page it was on originally. Anyway to get these to display within a url that can have some navigation?

wilderness

2:39 pm on Oct 27, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Unless you use a script or some type of session-ID-method, there's no full-proof way to prevent direct links.

Preventing inline-linking based upon referrals is one method, however it's not a 100% and there are certainly detriments.

lucy24

7:04 pm on Oct 27, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



The "referer" unfortunately doesn't distinguish between two things:

the page that requested the element
or
the link that was clicked to get the element

You can easily block requests that don't come from authorized referers such as your own site.

But the only way to prevent people from copy-and-pasting an image url directly into their browser window-- bypassing the usual forms of hotlink code-- is to block requests with a null referer. This would also exclude almost all robots-- you may or may not want this-- and also some browsers or IPs that don't send a referer with their legitimate requests. And of course you'd be blocking yourself if you ever wanted to view the online image in isolation, unless you put in a further condition to allow for your specific IP address or user-agent (whichever is more likely to be unique).