How to protect that images can be loaded only from server's PHP application?


working on development of php application that can display images.

images are stored on server.

how can i protect images, so they can not be accessed outside my php application?

is that possible to do with .htaccess?

thank you in advance!


However, the standard question deals with “piracy” and there is a pirate protection “script” in mod_rewrite just for that in the sticky threads and linked in my signature.



There are two options:

  1. Put the images in a directory below the DOCUMENT_ROOT
  2. Put the images in a directory in the DOCUMENT_ROOT and put an .htaccess file in that directory with the following:

deny from all

With both options you need to serve the images using a php file because browsers won’t be able to access the directly – which is what you want :slight_smile: