Disable Directory listing in Apache on RHEL/CentOS server – An easy way from Whm/cPanel

When you set up a new website, you can see a cgi-bin folder or something like that while accesing the website via browser. Directory listing is disabled by default in most servers these days for many reasons, one of them is security. We can simply enable/disable the directory listing option from the apache configuration file itself. Here I am explaining the ways to do the same on a server with or without a control panel. If a server have control panel like cPanel, we can simply manage this from the panel itself.

How to disable directory listing on a server without cPanel?

You can write on httpd.conf file to do the same in a server which hasn’t a control panel. Do follow the steps:

Step I : Login to server as root user.
Step II : Edit the Apache configuration file.

    Options ExecCGI FollowSymLinks IncludesNOEXEC Indexes SymLinksIfOwnerMatch
    Options Includes Indexes FollowSymLinks

Step III : Remove the word ‘Indexes‘ from options and save it and restart Apache.

# service httpd restart


Open httpd.conf >> Search "Options" >> Remove the word "Indexes" (Options Indexes FollowSymLinks) Or add additional line "Option -Idexes" >> Save file >> Restart Apache.

Now it wont shows the index list. If you don’t have the root/shell access then the easy way is to add index.html file to a folder to hide its listing from the public. The apache(httpd) service will always look inside a folder and try to read index.html first, if its not there then its lists the whole folder. So adding index.html file is very resourceful.

How to disable directory listing on a server with cPanel/WHM?

From WHM we can disable it globally. Read this article for more details >> How to disable directory indexes server wide – cPanel/WHM <<

If the server has a control panel like cPanel, we can simply disable the directory listing feature from the control panel itself for individual users.

Step I : Login to the cPanel.
Step II : Search “Index manager

cPanel – Index manager

Directory listing 1
Select a folder which you want to disable public listing

Directory listing 2
Eg /public_html/wp-admin

Directory listing 3

Choose no indexing for the folder. Repeat the step for the folders you want to disable indexing. If you have any problems with disabling indexing let me know by commenting below.


Related topics from CryBit:
1, Simple steps to install eAccelerator on cPanel server – Command-line option
2, How to prevent users from creating certain domains – WHM/cPanel

Ann Philip

I'm Ann, a freelancer in web-designing and also I have interest in blogging. I'm glad to be an editor/author in CryBit :-) Here, I will post some interesting web hosting + design related topics. Please let me know your suggestions as comment.

You may also like...

2 Responses

  1. vijay @ unix says:

    I always use htaccess for restricting access to folders. I create a htaccess in every folder and restrict access to it.

    This seems to be simple way of restricting access to directories. Thanks for sharing this with us.

Leave a Reply

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