If a folder on your website has no index.html or index.php file, visitors may see an "Index of /folder" page listing every file inside it. That's handy for a download folder, but usually it's something you want to hide. This guide shows how Instant Access Internet Services customers can turn directory listings on or off in cPanel with the Indexes tool, and how to do the same with .htaccess.
Why disable directory listing?
- It stops people browsing files you didn't mean to publish -- old backups, PDFs, spreadsheets, private images.
- It hides your folder structure and plugin names from attackers looking for weak spots.
- Search engines can't find and index stray files through the listing.
WordPress and most other website software already include index files in their main folders, but upload and custom folders often don't.
How to turn directory listings on or off with Indexes
- Log in to cPanel and go to Advanced > Indexes.
- If a window asks which directory to open, choose Web Root (your
public_htmlfolder) and continue. (You can change this later with the Settings button.) - Find the folder you want to change. Click a folder icon to open it, or click Up One Level to go back. To change your whole website, stay at
public_html. - Click Edit next to the folder.
- Choose one of the options:
- Inherit -- use the same setting as the parent folder (the default).
- No Indexing -- turn directory listing off. Visitors get a "403 Forbidden" message instead of a list of files.
- Show Filename Only -- turn directory listing on, showing a simple list of file names.
- Show Filename and Description -- turn directory listing on, with file sizes, types and dates.
- Click Save.
- Check the result: visit the folder in your browser, for example
https://example.com/files/, in a private window.
The setting applies to the folder and every folder inside it, unless a subfolder has its own setting. So choosing No Indexing on public_html turns listings off for your whole site, and you can still turn them back on for one download folder.
Alternative: use .htaccess
The Indexes tool simply writes a line to the .htaccess file in that folder. You can add it yourself in File Manager if you prefer:
- In cPanel, go to Files > File Manager and open the folder (for example
public_html). - Make sure hidden files are shown (Settings > Show Hidden Files (dotfiles)), then edit
.htaccess, or create it if it doesn't exist. - To turn listings off, add this line on its own:
To turn them on for a folder, use:Options -IndexesOptions +Indexes - Save the file.
Don't paste this into WordPress's .htaccess between the # BEGIN WordPress and # END WordPress lines -- WordPress can overwrite that block. Put it above it.
Troubleshooting
I turned listings on but still get 403 Forbidden
- Check the folder's permissions are 755 and the files are 644.
- A parent folder's
.htaccessmay haveOptions -Indexesor another rule blocking access. - If the folder is password-protected with Directory Privacy, you'll be asked to log in first.
I turned listings off but the files still show
Clear your browser cache, or try a private window. If you use LiteSpeed Cache, purge it. Also check that a subfolder doesn't have its own Options +Indexes line.
My home page now shows "403 Forbidden"
Your site is missing its index file. Make sure public_html contains index.html or index.php. Turning off directory listings only hides folders that have no index file -- it never blocks a real page.
Can I show a nicer page instead of 403 Forbidden?
Yes -- create a custom 403 page. See the custom error pages guide.
Related guides
- How to Show Hidden Files (.htaccess) in cPanel File Manager
- How to Create Custom Error Pages (404 and More) in cPanel
- How to Password-Protect a Folder with cPanel Directory Privacy
- File and Folder Permissions Explained (644 and 755)
Still stuck? Open a support ticket and the Instant Access Internet Services team will help.
