Prevent Indexing?

Discussion in 'Programming' started by Maverick88, Oct 29, 2007.

  1. #1
    Hi,

    I got 2 questions:
    1. How do I prevent visitors from indexing a site. For example when they visit:

    http://www.mysite.com/pictures/
    Code (markup):
    How do I prevent them from seeing all the files in this folder?
    I think it has to do something with .htaccess, but I am not sure.

    2. How to apply a 403 or a 401 error to a file or folder?

    Thanks in advance.
     
    Maverick88, Oct 29, 2007 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    You can create a file called index.html and save it there. Then they'll see this instead of the index.
     
    nico_swd, Oct 29, 2007 IP
  3. AstarothSolutions

    AstarothSolutions Peon

    Messages:
    2,680
    Likes Received:
    77
    Best Answers:
    0
    Trophy Points:
    0
    #3
    easiest way to stop directory browsing is to just put a file with the default name in it (index.html if you are using apache)
     
    AstarothSolutions, Oct 29, 2007 IP
  4. Maverick88

    Maverick88 Peon

    Messages:
    272
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #4
    But I will they see the main page? Won't they be redirected to index.html every time they visit www.mysite.com?
     
    Maverick88, Oct 29, 2007 IP
  5. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #5
    The index.html file only affects the folder where it's saved in. If you save it in "pictures", then your main page will remain the same. It'll only do what I said above: If you navigate to the directory, you'll just see the index.html file instead of the directory index.

    That's what you want, right? Index.html can be just a blank page...
     
    nico_swd, Oct 29, 2007 IP
  6. Synchronium

    Synchronium Active Member

    Messages:
    463
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    58
    #6
    Add this to your htaccess file:

    Options -Indexes
    Code (markup):
    Will give a 403 error instead of listing contents.
     
    Synchronium, Oct 30, 2007 IP
  7. Columbian

    Columbian Peon

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    i use the index.html trick....i even put a small message on it too :D

    "Can't View the Directory...Please dont try"
     
    Columbian, Oct 30, 2007 IP