SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Addict
    Join Date
    Nov 2009
    Posts
    312
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to protect image directory?

    Hi,

    My images folder currently lists all the images inside when I go to mysite.com/images. I want to prohibit direct access to the images folder. How can I have something like http://www.sitepoint.com/forums/images/ or http://w3schools.com/images/ ?

    Thanks.

  2. #2
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,321
    Mentioned
    462 Post(s)
    Tagged
    8 Thread(s)
    Just put a file inside the images folder called index.html. It can be blank, or can have a message such as "Access Denied". But with that file in there, it's not possible to view the contents of the folder in the way you described.

  3. #3
    SitePoint Addict
    Join Date
    Nov 2009
    Posts
    312
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by ralph.m View Post
    Just put a file inside the images folder called index.html. It can be blank, or can have a message such as "Access Denied". But with that file in there, it's not possible to view the contents of the folder in the way you described.
    Ralph, thanks for the quick answer. I have many subfolders in the images folder and it seems that I need to put an empty index.html file in every subfolder. Isn't there a better approach?

  4. #4
    SitePoint Member
    Join Date
    Sep 2011
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    also, if you are in a linux server you can prevent directory browsing via .htaccess

    Options All -Indexes

  5. #5
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by slicemee View Post
    also, if you are in a linux server you can prevent directory browsing via .htaccess

    Options All -Indexes
    You mean Apache...nothing to do with Linux.
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  6. #6
    SitePoint Member
    Join Date
    Sep 2011
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by logic_earth View Post
    You mean Apache...nothing to do with Linux.
    yes. Also, if it is nothing to do with linux you can try to include .htaccess files in Apache and Windows. Come here and tell me the results of yout attempt.

  7. #7
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,321
    Mentioned
    462 Post(s)
    Tagged
    8 Thread(s)
    Quote Originally Posted by ademmeda View Post
    I have many subfolders in the images folder and it seems that I need to put an empty index.html file in every subfolder. Isn't there a better approach?
    It doesn't take long to do that, though. I just do it as a standard thing every time I create a folder.

  8. #8
    SitePoint Addict
    Join Date
    Nov 2009
    Posts
    312
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by slicemee View Post
    also, if you are in a linux server you can prevent directory browsing via .htaccess

    Options All -Indexes
    Yes, this worked, thanks.

    Quote Originally Posted by ralph.m View Post
    It doesn't take long to do that, though. I just do it as a standard thing every time I create a folder.
    Ralph, even if it doesn't take any time I would always prefer a non-manual solution.

  9. #9
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by slicemee View Post
    yes. Also, if it is nothing to do with linux you can try to include .htaccess files in Apache and Windows. Come here and tell me the results of yout attempt.
    Works just fine on Windows. It works because it has nothing todo with the operating system Apache is running on.
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.



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
  •