SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Dec 2007
    Posts
    59
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

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

    hello,

    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!

  2. #2
    Utopia, Inc. silver trophy
    ScallioXTX's Avatar
    Join Date
    Aug 2008
    Location
    The Netherlands
    Posts
    9,084
    Mentioned
    153 Post(s)
    Tagged
    2 Thread(s)
    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:
    Code:
    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
    Rémon - Hosting Advisor

    SitePoint forums will switch to Discourse soon! Make sure you're ready for it!

    Minimal Bookmarks Tree
    My Google Chrome extension: browsing bookmarks made easy

  3. #3
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,653
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    Correct!

    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.

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •