Knowledge Base
MilesWeb / cPanel, How-Tos

How to Enable/Disable Directory Listing with .htaccess via cPanel?

Approx. read time : 3 min

Watch this video for a step by step process on How to Enable/Disable Directory Listing with .htaccess via cPanel

Directory listing is a crucial part of website hosting. As a cPanel user, you can enable or disable directory listing with .htaccess.

For security reasons, it is common for web servers to disable directory listing. You will get a 403 HTTP Forbidden Access error if you don’t have an index file in a directory. It does not allow the client to see the files in the directory. If you want to show these files, you have to enable the directory listing.

To Enable Directory Listing with .htaccess

1. Create a .htaccess file in the cPanel File Manager.

Just name the file as .htaccess.

If you already have the .htaccess file, find and edit the file in the cPanel File Manager.

For users who don’t know how to create/edit .htaccess file, refer to the article: How To Edit A .htaccess File Through The cPanel File Manager?

2. Enter/copy this code at the beginning of the file:

3. Click Save Changes and Close.

The next time you browse for the directory listing, it will display the index.

To Disable Directory Listing with .htaccess

1. Create/edit the .htaccess file in cPanel File Manager.

2. Enter/copy this code at the beginning of the file:

3. Click Save Changes and Close.

The next time you browse for the directory listing, it will display the 403 HTTP Forbidden Access error.

That is how you can configure the .htaccess file via cPanel to enable/disable directory listing.

Prasad Khartadkar
Prasad is a business grad specialized in Marketing. He has garnered experience as a technical content writer and a digital marketer that he brings out in his work. He likes reading classics and travel in his free time.