File.Index

Software version1.0
Operating SystemDebian 6
WebsiteWebsite

Introduction

The default Apache directory index listing is… (we can say it)… very ugly. Here is a theme I found on this site and which I have slightly modified. Here’s a preview:

Apachefileindex

Installation

It’s easy to install. Let’s say we want to place it in /var/www/include to make things easier:

1
2
3
4
wget /var/www/ http://www.deimos.fr/mytechnotebook/images/f/f8/Directory_index_theme.tgz
tar -xzf Directory_index_theme.tgz
rm -f Directory_index_theme.tgz
chown -Rf www-data. include

Configuration

Now we just need to configure Apache. Again, we’ll keep things simple and modify Apache’s base file:

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
<VirtualHost *:80>
	ServerAdmin webmaster@localhost

	DocumentRoot /var/www
	<Directory />
		Options FollowSymLinks
		AllowOverride None
	</Directory>
	<Directory /var/www/>
		Options Indexes FollowSymLinks MultiViews
		AllowOverride None
		Order allow,deny
		allow from all
	</Directory>

    Alias /icons/ /var/www/include/icons/
    Alias /include/ /var/www/include/
    <Location />
        <IfModule mod_autoindex.c>
          Options Indexes FollowSymLinks
          IndexOptions +FancyIndexing
          IndexOptions +VersionSort
          IndexOptions +HTMLTable
          IndexOptions +FoldersFirst
          IndexOptions +IconsAreLinks
          IndexOptions +IgnoreCase
          IndexOptions +SuppressDescription
          IndexOptions +SuppressHTMLPreamble
          IndexOptions +XHTML
          IndexOptions +IconWidth=16
          IndexOptions +IconHeight=16
          IndexOptions +NameWidth=*
          IndexOptions +DescriptionWidth=200
          IndexOrderDefault Descending Date
          HeaderName /include/header.html
          ReadmeName /include/footer.html
          AddIcon /icons/type_application.png .exe .app .EXE .APP
          AddIcon /icons/type_binary.png .bin .hqx .uu .BIN .HQX .UU
          AddIcon /icons/type_box.png .tar .tgz .tbz .tbz2 bundle .rar .TAR .TGZ .TBZ .TBZ2
          AddIcon /icons/type_rar.png .rar .RAR
          AddIcon /icons/type_html.png .htm .html .HTM .HTML
          AddIcon /icons/type_code.png .htx .htmls .dhtml .phtml .shtml .inc .ssi .c .cc .css .h .rb .js .rb .pl .py .sh .shar .csh .ksh .tcl .as
          AddIcon /icons/type_database.png .db .sqlite
          AddIcon /icons/type_disc.png .iso .image
          AddIcon /icons/type_document.png .ttf
          AddIcon /icons/type_excel.png .xlsx .xls .xlm .xlt .xla .xlb .xld .xlk .xll .xlv .xlw
          AddIcon /icons/type_flash.png .flv
          AddIcon /icons/type_illustrator.png .ai .eps .epsf .epsi
          AddIcon /icons/type_pdf.png .pdf
          AddIcon /icons/type_php.png .php .phps .php5 .php3 .php4 .phtm
          AddIcon /icons/type_photoshop.png .psd
          AddIcon /icons/type_monitor.png .ps
          AddIcon /icons/type_powerpoint.png .ppt .pptx .ppz .pot .pwz .ppa .pps .pow
          AddIcon /icons/type_swf.png .swf
          AddIcon /icons/type_text.png .tex .dvi
          AddIcon /icons/type_vcf.png .vcf .vcard
          AddIcon /icons/type_word.png .doc .docx
          AddIcon /icons/type_zip.png .Z .z .tgz .gz .zip
          AddIcon /icons/type_globe.png .wrl .wrl.gz .vrm .vrml .iv
          AddIcon /icons/type_android.gif .apk .APK

          AddIconByType (TXT,/icons/type_text.png) text/*
          AddIconByType (IMG,/icons/type_image.png) image/*
          AddIconByType (SND,/icons/type_audio.png) audio/*
          AddIconByType (VID,/icons/type_video.png) video/*
          AddIconByEncoding (CMP,/icons/type_box.png) x-compress x-gzip

          AddIcon /icons/back.png ..
          AddIcon /icons/information.png README INSTALL
          AddIcon /icons/type_folder.png ^^DIRECTORY^^
          AddIcon /icons/blank.png ^^BLANKICON^^

          DefaultIcon /icons/type_document.png
        </ifModule>
    </Location>

	ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
	<Directory "/usr/lib/cgi-bin">
		AllowOverride None
		Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
		Order allow,deny
		Allow from all
	</Directory>

	ErrorLog ${APACHE_LOG_DIR}/error.log

	# Possible values include: debug, info, notice, warn, error, crit,
	# alert, emerg.
	LogLevel warn

	CustomLog ${APACHE_LOG_DIR}/access.log combined

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>
</VirtualHost>

Adapt this configuration to your needs and then reload Apache:

1
/etc/init.d/apache2 reload

Resources

Last updated 09 Apr 2012, 13:15 CEST. history