If our website document directory does not have an index file, that time the Apache web server will show all the files and folder of the document root directory. Like as below image.
Edit apache virtual host file.
# vim /etc/httpd/conf/httpd.conf ## for centos/redhat
# vim /etc/apache2/apache2.conf ## for ubuntu/debian
|
Add following line into virtual host file
<Directory /var/www/html>
Options -Indexes
</Directory> |
Restart Apache
# service httpd restart ## for centos/redhat
# systemctl restart apache2 ## for ubuntu/debian
|
Now apache shows /index of look like this: