apache.htaccessmod-autoindex

Single theme folder for mod_autoindex with virtualhost


I succesfully installed (in localhost and virtualhost, running on OSX) Apaxy to have a better view of my web directories. Each .htaccess works fine if theme folder is in their same directory, but what if I want to keep only one theme folder, for example in /Library/WebServer/Documents? I tried to edit the vhost .htaccess from this working format:

AddIcon theme/icons/blank.png ^^BLANKICON^^
AddIcon theme/icons/folder.png ^^DIRECTORY^^
AddIcon theme/icons/folder-home.png ..
HeaderName theme/header.html
ReadmeName theme/footer.html
IndexStyleSheet theme/style.css

to this (not working):

AddIcon /Library/WebServer/Documents/theme/icons/blank.png ^^BLANKICON^^
AddIcon /Library/WebServer/Documents/theme/icons/folder.png ^^DIRECTORY^^
AddIcon /Library/WebServer/Documents/theme/icons/folder-home.png ..
HeaderName /Library/WebServer/Documents/theme/header.html
ReadmeName /Library/WebServer/Documents/theme/footer.html
IndexStyleSheet /Library/WebServer/Documents/theme/style.css

But I don't understand why, since it is just a path and I'm sure those files exist.

Does it only works if .htaccess and theme folder are in the same directory?

Is it possible to set all those mod_autoindex's directives in apache config file? In order to have it working for any directory missing the index page


Solution

  • AddIcon /Library/WebServer/Documents/theme/icons/blank.png ^^BLANKICON^^
    

    AddIcon expects a URL – whereas what you have here rather looks like a file system path.

    You need to specify the URL from the root of your domain – so if your icon is available via http://example.com/theme/icons/blank.png, you would need to use

    AddIcon /theme/icons/blank.png ^^BLANKICON^^
    

    Is it possible to set all those mod_autoindex's directives in apache config file?

    The Apache documentation tells you for every directive, in which context it can be used.

    Go look up for example the AddIcon directive, and you see that it says there:

    Context: server config, virtual host, directory, .htaccess