Updated: 28 September 2026 · Applies to: Apache 2.4 on AlmaLinux 9, Rocky Linux 9, Ubuntu 24.04 and Debian 12
On a server without cPanel, you turn off directory listing in the web server configuration. Visitors then see a 403 Forbidden page instead of a file list when a folder has no index file.
Apache
Edit the site's configuration: /etc/httpd/conf/httpd.conf or a file in /etc/httpd/conf.d/ on AlmaLinux, Rocky Linux and CentOS, or the site file in /etc/apache2/sites-available/ on Ubuntu and Debian. In the <Directory> block for your web root, remove Indexes from the Options line, or add a minus sign:
<Directory "/var/www/html">
Options -Indexes +FollowSymLinks
AllowOverride All
Require all granted
</Directory>
Check the configuration and reload Apache:
apachectl configtest systemctl reload httpd # AlmaLinux, Rocky Linux, CentOS systemctl reload apache2 # Ubuntu, Debian
Tip: If AllowOverride allows it, you can instead put Options -Indexes in a .htaccess file in the folder.
Nginx
Nginx does not list folders unless autoindex on; is set. Remove that line (or set autoindex off;), then run nginx -t and systemctl reload nginx.