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.
Mac OS XApache Web Server

Avatar of undefined
Last Comment
easiwriter45

8/22/2022 - Mon
Paulo Pimenta

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

ASKER
Thanks for the fast response. I've just tried this, but it had no effect.
Paulo Pimenta

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.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
Paulo Pimenta

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>
easiwriter45

ASKER
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.
Paulo Pimenta

Well, ".htaccess" itself may override some Apache configurations. It could be it.
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
strung

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.
strung

Meant meta "tag", not meta "link".
easiwriter45

ASKER
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.
Your help has saved me hundreds of hours of internet surfing.
fblack61
Paulo Pimenta

easiwriter45: This may be a stupid question, but what do you mean with "headings" in your previous post?
easiwriter45

ASKER
It's a directory listing with no content, just the col headings as shown in attached file.
dirlist.jpg
logicmatt

Use the -Indexes directive in your Apache config.
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
logicmatt

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
easiwriter45

ASKER
The answer was to remove indexes from the options in the user's conf file
ASKER CERTIFIED SOLUTION
Paulo Pimenta

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
easiwriter45

ASKER
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).
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck