+ Post New Thread
Results 1 to 9 of 9
How do you do....it? Thread, Disable directory listing in Technical; I've Googled this for answers, and they tell me to either add *Options -Indexes* to the .htaccess file in the ...
  1. #1

    beeswax's Avatar
    Join Date
    Jul 2005
    Location
    England
    Posts
    2,284
    Thank Post
    285
    Thanked 225 Times in 153 Posts
    Rep Power
    130

    Disable directory listing

    I've Googled this for answers, and they tell me to either add *Options -Indexes* to the .htaccess file in the root of my site, or to add similar to my http.conf file. I've restarted the Apache server but I can still access various directories.
    I'm using the Apache2Triad package on a W2K3 server.

  2. #2

    rob_f's Avatar
    Join Date
    May 2008
    Location
    Leeds
    Posts
    220
    Thank Post
    15
    Thanked 73 Times in 56 Posts
    Rep Power
    25
    In httpd.conf look for the section that looks like

    <Directory />

    and you should see something like the following after it:

    Options Indexes FollowSymLinks

    To disable directory listing, just remove ‘Indexes’ from this line or change ‘Indexes’ to ‘-Indexes’

    Make sure to restart your Apache server afterwards and clear your webcache if there's any in the way.
    Last edited by rob_f; 14th May 2008 at 09:06 AM.

  3. #3

    rob_f's Avatar
    Join Date
    May 2008
    Location
    Leeds
    Posts
    220
    Thank Post
    15
    Thanked 73 Times in 56 Posts
    Rep Power
    25
    The problem you'll have with .htaccess on windows is that you can't actually create a file called .htaccess - you need something before the dot in a filename.

    In your httpd.conf file there is a line that should look like

    AccessFileName .htaccess

    Change this to something else - ht.access or something, restart apache and then you can change settings at a directory level by creating ht.access files in the applicable directory.

  4. #4

    Join Date
    Feb 2006
    Location
    Derbyshire
    Posts
    1,381
    Thank Post
    181
    Thanked 211 Times in 171 Posts
    Rep Power
    64
    If you're struggling and need a quick fix, there's always the old chuck a blank index.htm files in directories while you're fighting with it trick

  5. #5
    Ryan's Avatar
    Join Date
    Jan 2008
    Location
    Scotland
    Posts
    537
    Thank Post
    12
    Thanked 16 Times in 15 Posts
    Blog Entries
    1
    Rep Power
    28
    Yep, done that plenty times Could also add a meta refresh to redirect. Cheesy, but an option.

  6. #6

    rob_f's Avatar
    Join Date
    May 2008
    Location
    Leeds
    Posts
    220
    Thank Post
    15
    Thanked 73 Times in 56 Posts
    Rep Power
    25
    All viable options , however if you're serious about using apache as a production webserver it's vastly beneficial to get to grips with the httpd.conf file.

  7. #7

    beeswax's Avatar
    Join Date
    Jul 2005
    Location
    England
    Posts
    2,284
    Thank Post
    285
    Thanked 225 Times in 153 Posts
    Rep Power
    130
    Quote Originally Posted by rob_f View Post
    In httpd.conf look for the section that looks like

    <Directory />

    and you should see something like the following after it:

    Options Indexes FollowSymLinks

    To disable directory listing, just remove ‘Indexes’ from this line or change ‘Indexes’ to ‘-Indexes’

    Make sure to restart your Apache server afterwards and clear your webcache if there's any in the way.

    The problem you'll have with .htaccess on windows is that you can't actually create a file called .htaccess - you need something before the dot in a filename.

    In your httpd.conf file there is a line that should look like

    AccessFileName .htaccess

    Change this to something else - ht.access or something, restart apache and then you can change settings at a directory level by creating ht.access files in the applicable directory.
    Sorry to have been away from this post so long. Can I get this clear in my head, are you advocating that I change a line of code in the httpd.conf file, and then rename .htaccess, as well as changing Indexes to -Indexes?

  8. #8

    rob_f's Avatar
    Join Date
    May 2008
    Location
    Leeds
    Posts
    220
    Thank Post
    15
    Thanked 73 Times in 56 Posts
    Rep Power
    25
    Nope, if you modify the indexes directive in httpd.conf then that will apply to everything defined by the directory section.

    .htaccess applies to when you make changes like this on a per-directory basis by creating a .htaccess file in a particular directory.

    The best way to do things would be to disallow indexes in httpd.conf and then if you need to have a directory index anywhere, create a .htaccess (or indeed ht.access) file in the directory you want listing.

    I hope i've made this a little clearer, apologies for my initial conflicting statement!


    Rob.

  9. 2 Thanks to rob_f:

    beeswax (22nd May 2008), FN-GM (24th June 2008)

  10. #9

    beeswax's Avatar
    Join Date
    Jul 2005
    Location
    England
    Posts
    2,284
    Thank Post
    285
    Thanked 225 Times in 153 Posts
    Rep Power
    130
    Just to update you on this, I eventually found the correct place, *htdocs config* which to modify. Which is now common sense, but at the time appeared tricky. Ta.

SHARE:
+ Post New Thread

Similar Threads

  1. Tools to use for listing network connections?
    By speckytecky in forum Wireless Networks
    Replies: 4
    Last Post: 11th September 2007, 09:53 AM
  2. Replies: 0
    Last Post: 21st May 2007, 11:10 AM
  3. Listing of Vista Drivers
    By Geoff in forum Windows Vista
    Replies: 2
    Last Post: 23rd February 2007, 02:07 PM
  4. Listing and terminating remote programs/processes
    By wesleyw in forum How do you do....it?
    Replies: 4
    Last Post: 20th December 2006, 01:38 PM
  5. Useful(?) to some - OSS listing on the web.
    By indiegirl in forum Educational Software
    Replies: 0
    Last Post: 24th July 2006, 11:50 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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