Preventing browsing of folders

Discussion in 'HTML & Website Design' started by bluemanteam, Jan 2, 2008.

  1. #1
    On my wordpress blog, I have a number of directories and subdirectories.

    Rather then place an index.htm file in each directory, is there a global command that can be applied site wide to prevent people from viewing the contents of each of the various folders?
     
    bluemanteam, Jan 2, 2008 IP
  2. WebGeek182

    WebGeek182 Active Member

    Messages:
    510
    Likes Received:
    28
    Best Answers:
    0
    Trophy Points:
    95
    #2
    Yes, it's an easy fix if you're on an Apache server. Either create an .htaccess file or edit your current one (in your site's public root), and add the following to the beginning of the file:

    Options All -Indexes
    Code (markup):
     
    WebGeek182, Jan 2, 2008 IP
  3. bluemanteam

    bluemanteam Peon

    Messages:
    169
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thank you, that worked great.

    Rather then give them a generic error message, can you redirect them to a custom error page?
     
    bluemanteam, Jan 2, 2008 IP
  4. venam

    venam Peon

    Messages:
    32
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    i am interested to! how do i redirect them on a custom error page or on the main site?
     
    venam, Jan 15, 2008 IP
  5. WebGeek182

    WebGeek182 Active Member

    Messages:
    510
    Likes Received:
    28
    Best Answers:
    0
    Trophy Points:
    95
    #5
    Yes, you can use custom error pages. First create your error pages. Do a little research to find what the appropriate codes are, and which common errors you want to use. You're usually safe starting with 404 (Not Found) and 403 (Restricted). Then add the following to your .htaccess:

    ErrorDocument 403 /403.php
    ErrorDocument 404 /404.php
    Code (markup):
    Add a new line for each error code you are adding, and replace the 403.php and 404.php with the name of your corresponding page.
     
    WebGeek182, Jan 18, 2008 IP