Hiding/Prevent Access To /images/ Folder?

Discussion in 'Web Design and Development' started by JonHimself, May 26, 2009.

  1. JonHimself macrumors 68000

    JonHimself

    Joined:
    Nov 3, 2004
    Location:
    Toronto, Ontario
    #1
    I was hoping to get some help here. I have a website to show-off concert photos that I take and it's really basic... just the lighbox script to have each concert set pop-up in its own album.
    I'm not concerned about people taking my pictures or using them for whatever but would rather control that myself (ie just send anyone who is interested a link to download them).
    I've noticed that when I type in my url.com/images/ I am able to see all of the files and sub folders and browse right to the specific concert albums. I know that I've tried doing this on other web-sites to download some pictures but have been unable to. Does anyone know if it's possible to block access to those folders simply by typing in the URL?
     
  2. edesignuk Moderator emeritus

    edesignuk

    Joined:
    Mar 25, 2002
    Location:
    London, England
    #2
    Create a file called ".htaccess" (without quotes!) and put this in it:

    May as well put it at the top of your directory structure, this way directory indexing will be disabled for all sub-folders.
     
  3. JonHimself thread starter macrumors 68000

    JonHimself

    Joined:
    Nov 3, 2004
    Location:
    Toronto, Ontario
    #3
    That's great, thanks!

    So can I just type that out in text edit or something and then rename it and remove any extensions?
     
  4. edesignuk Moderator emeritus

    edesignuk

    Joined:
    Mar 25, 2002
    Location:
    London, England
    #4
    Yup, it's just a flat text file with no extension. Make sure it's CHMOD'd to 644 too on the server.

    Be careful with TextEdit, it still might leave it as RichText or something.
     
  5. JonHimself thread starter macrumors 68000

    JonHimself

    Joined:
    Nov 3, 2004
    Location:
    Toronto, Ontario
    #5
    Yeah, there's way to change that so that it strips the RTF (or something like that). I remember coming across it when I was reading about something else.

    Also, when you say make sure it's CHMOD'd, could you explain a little more? I spent the last little while trying to understand what CHMOD was all about and what I might have to do to do what you've said but am lost. To put it in context, I use Dreamweaver, know HTML and after a year or two of not learning any web-related coding I've started to understand CSS... so I'm not exactly 'advanced'.
     
  6. edesignuk Moderator emeritus

    edesignuk

    Joined:
    Mar 25, 2002
    Location:
    London, England
    #6
    Through your FTP client you should see an option to CHMOD. CHMOD is just setting permission for the file. 644 is what this file should be set to.
     
  7. JonHimself thread starter macrumors 68000

    JonHimself

    Joined:
    Nov 3, 2004
    Location:
    Toronto, Ontario
    #7
    Thanks again! I'll look for that later when I attempt this!
     
  8. kAoTiX macrumors 6502

    kAoTiX

    Joined:
    Oct 14, 2008
    Location:
    Midlands, UK
    #8
    Also if you add an index.html (.htm .php .asp) into the /images/ directory with nothing in it or redirect people will also not be able to list the images in the directory.
     

Share This Page