Link to home
Start Free TrialLog in
Avatar of easiwriter45
easiwriter45

asked on

How do I disable directory listing in Apache2

I just upgraded my Mac OS Tiger system to Leopard and it screwed up the Apache configuration. I've managed to reconfigure it so that everything works as before apart from one thing. If I send a page request such as http://localhost/myuser/sitename and there is no index.html (or one of the others for DirectoryIndex) then it returns a listing of the directory. It didn't do this before and I can't turn it off no matter what I try.

Can someone who understands Apache sort me out please.
Avatar of Paulo Pimenta
Paulo Pimenta
Flag of Portugal image

Add this line...
IndexIgnore *
... to "httpd.conf" in Apache's "conf" folder
Avatar of easiwriter45
easiwriter45

ASKER

Thanks for the fast response. I've just tried this, but it had no effect.
I remenber doing this once, one I had the same problem.
I opened httpd.conf file and search for the "Indexes" and delete every occurance that was commented.
This mainly appear on the Options parameter of the folder's definition.
Try it out.
I used to have, for exemple, this definition for the root folder...
<Directory />
    Options Indexes FollowSymLinks
    AllowOverride None
</Directory>
... and I just took out Indexes, as can be seen below
<Directory />
    Options FollowSymLinks
    AllowOverride None
</Directory>
I looked at IgnoreIndex again and realised that I'd put it in the wrong place. It now stops the contents of the directory being listed, but still returns the headings. Before I installed Leopard it produced an http error of some sort (I think). I'd tried taking out Indexes before, but that had no effect. Now I'm wondering if .htaccess was being used in some way.
Well, ".htaccess" itself may override some Apache configurations. It could be it.
Depending on how many subdirectories you have you could alway put an index.html file in each subdirectory with a meta link automatically redirecting the user to the main home page. You would only have to create one of these and just put copies in each subdirectory.
Meant meta "tag", not meta "link".
Thing is, before I installed Leopard this problem didn't exist. What I need to know is what did that change, then it could be reversed.
easiwriter45: This may be a stupid question, but what do you mean with "headings" in your previous post?
It's a directory listing with no content, just the col headings as shown in attached file.
dirlist.jpg
Use the -Indexes directive in your Apache config.
Even better, if you know that you'll never want auto-indexing enabled, comment out the loading of the auto_index module in your httpd.conf config file:

#LoadModule autoindex_module modules/mod_autoindex.so
The answer was to remove indexes from the options in the user's conf file
ASKER CERTIFIED SOLUTION
Avatar of Paulo Pimenta
Paulo Pimenta
Flag of Portugal image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks, for your solution, but it didn't help at first because httpd.conf, doesn't have that option set on my installation. I had to remove the option from my user's .conf file, which I wasn't aware existed until today (I'm a novice as far as Apache is concerned).