How do I hide and show the files and directories on my website?
When I go to
example.com, I see all the files on my website instead of a 404 or 403 error. How can I disable this? Also, how do I enable this?
The feature you are looking for is
mod_autoindex in Apache. You can read the full documentation here, but in a nutshell, you want to add
to your Apache virtual host configuration in the directory you want to disable. To enable them, you want to use
In Nginx, the equivalent is
ngx_http_autoindex_module. You can read the full documentation on this here. While it is set to off by default, you can explicitly turn it on/off with the following inside a location block of your virtual host configuration:
To enable it, you would use