How do I hide and show the files and directories on my website?
Linode
Linode Staff
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?
1 Reply
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
Options -Indexes
to your Apache virtual host configuration in the directory you want to disable. To enable them, you want to use
Options +Indexes
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:
autoindex off;
To enable it, you would use
autoindex on;