apache HeaderName directive of mod_autoindex does not take effect

4.4k views Asked by At

i cannot let my file listing prepend with a html file called header.html. below is my whole httpd.conf file.

#basic config
ServerRoot "D:/phpnow/Apache-22"
Listen 8888
ServerAdmin [email protected]
ServerName localhost
DocumentRoot "D:/"
Options Indexes
#dir_module
LoadModule dir_module modules/mod_dir.so
#<IfModule dir_module>
#    DirectoryIndex index.html
#</IfModule>
#alias_module
LoadModule alias_module modules/mod_alias.so

#autoindex_module
#Alias /icons/ "D:/phpnow/Apache-22/icons/"
LoadModule autoindex_module modules/mod_autoindex.so
DefaultIcon /icons/unknown.gif
IndexOptions FancyIndexing  
HeaderName /header.html

header.html is located at d:\header.html

content of the header is :

test

web browser output is :

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
 <head>
  <title>Index of /</title>
 </head>
 <body>
<h1>Index of /</h1>
<pre>      <a href="?C=N;O=D">Name</a>                    <a href="?C=M;O=A">Last modified</a>      <a href="?C=S;O=A">Size</a>  <a href="?C=D;O=A">Description</a><hr><img src="/icons/unknown.gif" alt="[DIR]"> <a href="$RECYCLE.BIN/">$RECYCLE.BIN/</a>           09-Jan-2011 17:59    -   

<img src="/icons/unknown.gif" alt="[DIR]"> <a href="test/">test/</a>               26-Dec-2010 21:10    -  
<hr></pre>

</body></html>
2

There are 2 answers

0
Bachsau On

HeaderName must resolve to a document with a major content type of text/* (e.g., text/html, text/plain, etc.). On windows you need to have AddType text/html .html somewhere in your configuration.

1
codeine On

If you're using Apache 2.2 make sure you've uncommented the line to use Fancy directory listings in httpd.conf

Include conf/extra/httpd-autoindex.conf