When a visitor lands on “Index of /” — a plain Apache file listing with links to every file and folder — instead of your homepage, two things are true at once: Apache could not find an index file to serve, and directory indexing (Options +Indexes) is enabled so it listed the folder rather than refusing. That listing is also an information leak: it exposes filenames, backup archives, .sql dumps, and wp-config neighbours to anyone who guesses the URL. The fix is to give Apache an index file to serve and to turn directory listing off so an empty folder returns 403 instead of a public directory tree.
What’s happening
Apache resolves a request for a directory (a URL ending in /, or a bare domain) by looking through its DirectoryIndex list — index.html, index.php, index.htm, and so on. If it finds one, it serves it. If it finds none, its behaviour depends on Options: with +Indexes it generates the “Index of /” listing; with -Indexes it returns 403 Forbidden. So you get the listing only when both conditions line up — no index file and indexing on.
The common ways this happens on cPanel: a site was uploaded but the homepage is named home.html or default.html instead of index.*; files were placed one level off (in public_html/ while the domain’s docroot is a subfolder, or vice versa); a fresh addon domain has an empty docroot; or an .htaccess somewhere set Options +Indexes deliberately for one folder and it is now exposing a directory that should be private. cPanel’s default for new accounts is usually to disable indexing, but copied .htaccess files and inherited servers frequently re-enable it.
How to verify
Check whether an index file exists where the request lands, and where the docroot actually points.
# Is there an index file in this directory?
ls -la /home/<cpaneluser>/public_html/index.*
ls -la /home/<cpaneluser>/public_html/
# Where does this domain's document root point?
grep -i "<domain>" /etc/userdatadomains
cat /var/cpanel/userdata/<cpaneluser>/<domain> | grep -i documentroot
Find out whether indexing is on, and where it is being set.
# Look for an Indexes directive in the account's .htaccess files
grep -rniE 'options.*indexes' /home/<cpaneluser>/public_html/
find /home/<cpaneluser>/public_html -name .htaccess
# Confirm what Apache returns for the bare directory
curl -sI https://example.com/ | head -1
curl -s https://example.com/ | grep -i 'Index of'
If the server-wide default is the question, check the global indexing setting rather than guessing per account:
# Server-wide Options often live in the Apache main config / includes
grep -rniE 'options.*indexes' /etc/apache2/conf.d/ /etc/apache2/conf/ 2>/dev/null
The fix
- Add the missing index file — the simplest and most common fix. Upload or create
index.html(orindex.phpfor a dynamic site) in the directory that is listing. If the homepage is named something else (home.html,default.htm), either rename it toindex.htmlor add its name to theDirectoryIndexvia.htaccess:DirectoryIndex index.php index.html home.html. - Disable directory listing in .htaccess — to stop any empty folder leaking its contents, add
Options -Indexesto the document root’s.htaccess. From then on a directory with no index file returns 403 instead of a public listing. This is the line you want on essentially every production site. - Turn off Indexing in cPanel — cPanel has a UI for this: cPanel » Advanced » Indexes lets you set a folder to “No Indexing” without touching
.htaccessby hand. Set the document root (and any sensitive subfolders) to No Indexing. - Fix files in the wrong document root — if
grep documentrootshows the domain points at a subfolder but your files (including the index) are one level up, the directory that lists is genuinely empty of an index. Move the files into the real docroot, or repoint the docroot (see the 404 runbook). The listing disappears once the index file is where the domain looks. - Remove a deliberate +Indexes you do not want —
grepfoundOptions +Indexesin an.htaccess. If it was inherited from a copied site or a “file share” folder that should no longer be public, change it to-Indexesor delete the line. Confirm which directory it governs before removing — a few setups intentionally list a downloads folder. - Set the server-wide default — if many accounts list directories, the global default has indexing on. Disable it for new and existing vhosts via WHM » Apache Configuration » Global Configuration (Directory “Options”) or the include editor, so the safe behaviour is the default rather than per-account cleanup.
- Treat the exposure as a leak, not just cosmetics — a directory listing may have already exposed
database.sql,backup.zip, or config files. After closing the listing, review what was visible and rotate any credentials that sat in a downloadable file. Closing the listing does not un-expose what was already indexed by bots.
Once an index file is in place and Options -Indexes (or cPanel’s No Indexing) is set, reload the bare directory and confirm you get the site or a clean 403 — never the “Index of /” page. A 403 on an empty folder is the safe outcome you want. Stack Harbor handles cPanel directory-indexing and exposure cleanup under cPanel/WHM management — start a conversation.