How do i disable or enable directory browsing?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
gnel2000
Forum Newbie
Posts: 16
Joined: Tue Jul 26, 2005 10:41 pm

How do i disable or enable directory browsing?

Post by gnel2000 »

Hi all,
i have a problem here. I try to disable a directory browsing features at one of my directory with .htaccess.
I have gone thru many article which teach to at this line "Options +Indexes" in the .htaccess and place it in the directory i would like to disable the directory browsing.
But the problem is, i tried this method many time but still cannot get it done.
Is it what i did is wrong? Any idea?

p/s: i dont have the control of the apache configuration file.
theda
Forum Contributor
Posts: 332
Joined: Sat Feb 19, 2005 8:35 am
Location: USA

Post by theda »

If you only want to keep people from viewing a list of contents in a directory, you can easily just put an index.php/.html in there and anytime someone tries to view the directory list, it'll just load the index page. If you don't want them to view anything in that directory, you should be able to add a username/password to a .htaccess file, other than that, you're a tad bit out of luck unless you like a ton of work ^_^;
gnel2000
Forum Newbie
Posts: 16
Joined: Tue Jul 26, 2005 10:41 pm

Post by gnel2000 »

i was suggested that to the management, but they felt is very trouble to add an index file in every directory. anyway, thank for the info.

but i still wondering how the .htaccess work with only one line : Options Indexes?
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

You need to make sure you are allowed to override the settings in a .htacess file...

For example the following in httpd.conf gives the user to use .htaccess freely

Code: Select all

<VirtualHost *:80>
  ServerName localhost
  DocumentRoot &quote;F:/websites/localhost&quote;
  <Directory &quote;F:/websites/localhost&quote;>
    AllowOverride All
    Options All
  </Directory>
</Virtualhost>
Post Reply