How To Disable Directory Listing in cPanel

By default in cPanel, if you don't upload an index.html, index.php, or index.htm file, when you load your domain in a browser you will see an "Index of /" page showing the folder contents for your domain when you load it in a web browser.

 

blobid0.png

Usually this can be fixed by simply uploading your site's content or adding an index.html file with a Coming Soon page until you have completed designing your site. But if you would like turn off directory listing entirely, this can be easily accomplished within cPanel.

 

1. Login to cPanel and click the button called Indexes under ADVANCED.

blobid1.png

 

 2. Click the Edit button next to public_html or the folder for your domain, such as /domain.com/ 

blobid2.png

blobid3.png

3. Select No Indexing and then click Save.

blobid4.png

 

Now that you have disabled directory listing, the domain will show a 403 error when loading a domain that is a missing an index.html or index.php file. This is better for security, but it is recommended to add an empty index.php or index.html file to get rid of this error message.


If you would like to change the name of the file that loads automatically to something other than index.html or index.php, you can add a couple lines of code to an empty file called .htaccess. The name that you choose will be the first page of your website that loads when you load your domain name in a browser.

 

#Change default index page
DirectoryIndex MyNewIndexPage.html

With this code added to an empty .htaccess file or the current .htaccess for your website, you can change the default first page of your site to MyNewIndexPage.html or any title of a file you would like to load automatically in place of index.html or index.php.

Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.