-1

For my core php website, I want to restrict the user to aceess the image link. Currently we have blocked the right click on the website; however, anyone can still access the website code via source code on any browser and find the links to the product images. So I want to restrict the user to access the image path from source code also.

I have tried with htaccess but it will restrict only directory listing not the particular images.

Thanks in advance!

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
Narayan
  • 1,670
  • 1
  • 19
  • 37
  • @SanjitBhardwaj both are the different questions. its not duplicate. – Narayan Jan 25 '18 at 07:26
  • What is your intent for restricting access to the images? If the problem you're trying to solve is people stealing and reusing your images without credit, you can always place watermarks on them. (I recall that using either `GD` or `imagemagick` from within PHP can do this for you.) Alternately, you could try base64 encoding the images and place them inline, but that won't necessarily restrict their access, only increase the difficulty in a casual user getting the image. – Agi Hammerthief Jan 25 '18 at 07:27
  • 2
    The criteria for duplication, as I understand it, is not whether the question is exactly the same, but whether the answer is applicable to it. In this case (same end goal), yes, your question is a duplicate. – Agi Hammerthief Jan 25 '18 at 07:30
  • @AgiHammerthief Site is already live which contain arount 2 thousand images. So at this stage it is not possible to place a watermark to all images or try with base64. – Narayan Jan 25 '18 at 07:33
  • If I understand your statement correctly, it's not possible to write [three lines of base64 "obfuscation" code](https://stackoverflow.com/a/11895715/2225787) in a single function somewhere and call it in around 2000 places. – Agi Hammerthief Jan 25 '18 at 07:39
  • Why wouldn't it be possible to (batch) place watermarks on existing images? – brombeer Jan 25 '18 at 07:44
  • 1
    What exactly you're trying to achieve with this? If an image is somehow available for users to view, it can at least be screenshot (and cropped etc.). – brombeer Jan 25 '18 at 07:48

1 Answers1

-1
  1. If the image is dynamically served, then you can add a piece code (PHP code for anti hotlinking) to the dynamic loader to add watermark or use Data URI Scheme.

  2. Sure you can write and run a script to:

    • scan the image folder to add watermark or create Data URI for each image

    • scan all static HTML file to change the img src to Data URI

The key is to write a short script to do all the things in seconds.

ild flue
  • 1,323
  • 8
  • 9