Enabling Fancy Directory Indexing on Apache 2.x

What is Fancy Directory Index?

 

If you don’t put the index.html or index.php files in your web directory, apache use to list all the files / directory when you access that directory. This feature is helpful if you are running a public download website. Apache Fancy Directory Indexing module (mod_autoindex) is of same type but with more features than the default. Below screencaps is an example for with and without fancy index’s.

 

Without Apache Fancy index

 

With Apache Fancy Directory Index

 

 

Enabling Fancy Directory Indexing in Cpanel

 

Enabling is pretty simple if you have a cpanel server, the mod_autoindex use to be installed by default. You just need to add few lines in httpd.conf to get it started.

 

 

  • # cd /usr/local/apache/conf/extra

and verify that httpd-autoindex.conf exists, do not alter any of the settings. Open the httpd.conf file

 

  • # vi /usr/local/apache/conf/httpd.conf

 

And add the below lines before or after the “IfModule” entries

 

<IfModule mod_autoindex.c>
IndexOptions FancyIndexing IconHeight=16 IconWidth=16
</IfModule>

 

You can adjust the IconHeight & IconWidth according to your taste. Save your work and exit, now rebuild the httpd.conf file using.

 

  • # /usr/local/cpanel/bin/apache_conf_distiller –update

 

Rebuild the httpd.conf with the new setting using :

 

  • # /usr/local/cpanel/bin/build_apache_conf

 

Restart the apache server to load the new changes.

 

Enabling Fancy Directory Indexing in Plesk / Directadmin

 

Since plesk uses the httpd rpm build the mod_autoindex use to be installed by default. You just need to add the following lines in the httpd.conf below of after the “IfModule” entries.

 

  • # vi /etc/httpd/conf/httpd.conf

 

<IfModule mod_autoindex.c>
IndexOptions FancyIndexing IconHeight=16 IconWidth=16
</IfModule>

 

Save your works and restart the apache web server to load the new configuration. If you just want to enable it for a single domain (not for all the accounts in the server), just add the <IfModule> line in the public_html or httdocs .htaccess file to enable it.