How to disable ‘directory listing’ in Apache web server?

Do you have WHM access to your server? Then it’s simple, do the steps in >> disable directory indexes server wide – cPanel/WHM <<

Disabling the directory listing option in Apache web server will improve the total server security and also it will reduce the chance of server hack. We can do it from the Apache configuration file itself. Enabling this feature lists all files and folders in a directory on the web browser when there is no index file on that particular directory. Here I’m explaining the steps to edit Apache configuration file to disable directory index option.

If you have a control panel like cPanel, you can manage it simply from the panel itself, that we already discussed.

Open your Apache conf file with your favorite editor and make the changes as pasted below:

Steps to disable directory listing/indexes

Step 1 : SSH to server as root.

Step 2 : To check, run this:

# grep Options /etc/httpd/conf/httpd.conf

Sample output:

# grep Options /etc/httpd/conf/httpd.conf
    Options ExecCGI FollowSymLinks IncludesNOEXEC Indexes SymLinksIfOwnerMatch
    Options Includes Indexes FollowSymLinks
    Options None

Step 3 : Open the Apache configuration file, remove the word ‘Indexes‘ from options then save it and restart the Apache service.

# service httpd restart

That’s it!! Now check the directory via web browser you can see the change.

FAQ

1. Yes I know this, but I have WHM on my server. How disable directory indexes server wide via WHM panel?

This is also simple, this can be done from Home » Service Configuration » Apache Configuration » Global Configuration. Read this article for more details >> How to disable directory indexes server wide – cPanel/WHM <<

2. I want to disable this feature only for one account in my WHM server, is it possible?

Yeah, it’s. Please read this article, for cPanel. Ping me, if you need any help.

Arunlal Ashok

Linux Server Administrator. I’m managing Linux servers since 2012. I started this blog to share and discuss my ideas.

Any questions? Write to arun (@) crybit.com

You may also like...

2 Responses

  1. December 28, 2013

    […] topics How to disable ‘Directory listing’ in Apache web server? How to change the apache port via command line in […]

  2. December 28, 2013

    […] links: How to enable mod_deflate in apache How to disable ‘Directory listing’ in Apache web server? How to change the apache port via command line in […]

Leave a Reply

Your email address will not be published. Required fields are marked *