Disabling Autoindexing in Apache2, Ubuntu 12.04

By default, Apache2 autoindexes the document roots for your website. This means that anyone typing in the URL of a directory that does not contain index.html will be shown a listing of all directory contents. By disabling autoindexing, Apache no long indexes directory contents and instead returns a 404 error when trying to browse a directory. To disable autoindexing:

sudo a2dismod autoindex
sudo service apache2 restart