1

Has anyone here managed to get FancyIndexing working in Apache 2.4? - I have found plenty of guides, but they are all at least 5-9 years out of date and do not work with Apache 2.4.

According to the documentation, FancyIndexing comes under mod_autoindex (which is enabled by default), and all that is required to get it working on a most basic level is Options +Indexes in a directory block, like so:

<Directory "/var/www">
        #
        # Possible values for the Options directive are "None", "All",
        # or any combination of:
        #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
        #
        # Note that "MultiViews" must be named *explicitly* --- "Options All"
        # doesn't give it to you.
        #
        # The Options directive is both complicated and important.  Please see
        # http://httpd.apache.org/docs/2.4/mod/core.html#options
        # for more information.
        #
        Options Indexes FollowSymLinks

        #
        # AllowOverride controls what directives may be placed in .htaccess files.
        # It can be "All", "None", or any combination of the keywords:
        #   Options FileInfo AuthConfig Limit
        #
        AllowOverride None

        #
        # Controls who can get stuff from this server.
        #
        Require all granted
</Directory>

The problem is that it is not working: if I have a blank index page...

# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
<IfModule dir_module>
    DirectoryIndex index.htm
</IfModule>

...the index page overrides the indexing, or:

# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
<IfModule dir_module>
    DirectoryIndex disabled
</IfModule>

...causes the default Apache placeholder webpage to be displayed, as does simply removing the index page.

I should also mention that what I am trying to achieve is an index view of my web-directory in order to avoid having to implement a mess of linked pages. - The website is intended as a resource site, so visitors can simply move directly to the page or the resouce that they want with no messing around. Also, at this point, FancyIndexing is not absolutely essential, as I should be able to 'upgrade' to that once I have indexing working.

=======================================================================

This is additional to my comments, and is in further reply to Anaksunaman's answer, with my own notes and observations:

Find the LoadModule directive for autoindex_module in httpd.conf and make sure it is uncommented:

LoadModule autoindex_module modules/mod_autoindex.so

Yes, I included that, as can be seen below:

# Dynamic Shared Object (DSO) Support
#
# To be able to use the functionality of a module which was built as a DSO you
# have to place corresponding `LoadModule' lines at this location so the
# directives contained in it are actually available _before_ they are used.
# Statically compiled modules (those listed by `httpd -l') do not need
# to be loaded here.
#
# Example:
# LoadModule foo_module modules/mod_foo.so
#
Include conf.modules.d/*.conf
LoadModule autoindex_module modules/mod_autoindex.so

Make sure Indexes is added to your Options directive under the Directory block for your DocumentRoot. In your case, your Options directive appears fine e.g.:

Options Indexes FollowSymLinks

Not quite: there is (on Cent OS / RHEL / Red Hat / Fedora, at least) a nasty gotcha in the form of /etc/httpd/conf.d/welcome.conf. - The Options -Indexes entry needs to be amended to either Options Indexes or Options +Indexes, otherwise the indexing will not work and there will be a client denied by server configuration: /var/www type error in the log file.

In httpd-autoindex.conf, make sure:

Your IndexOptions directive has FancyIndexing listed e.g. IndexOptions FancyIndexing HTMLTable VersionSort.

Alias /icons/ is pointed at the correct directory for your icons e.g. Alias /icons/ "/path/to/Apache24/icons/"

The Directory block for your icon path uses the same path as Alias /icons/ e.g

This is no longer necessary, as it is all now pre-configured (for the basic indexing and fancy indexing, at least), with an IndexOptions block for the addition of further configuration options.

1

Note that, as indicated by Y Treehugger Cymru:

  • With the exception of Step 4 (uncommenting the entry for e.g. httpd-autoindex.conf), the items listed in each step below are generally already enabled by default, likely with correct values.

  • The exact names and locations of the files containing each relevant entry may vary somewhat, based on your distribution of Apache (e.g. "httpd-autoindex.conf" may be "autoindex.conf", for example).

  • Regarding Step 2, Red Hat based distributions (CentOS/RHEL/Fedora, etc.) apparently also need to have Options -Indexes in /etc/httpd/conf.d/welcome.conf changed to either Options Indexes or Options +Indexes. Otherwise, indexing apparently will not work correctly.


To get FancyIndexing to work in Apache 2.4:

  1. Find the LoadModule directive for autoindex_module in httpd.conf and make sure it is uncommented:

    LoadModule autoindex_module modules/mod_autoindex.so
    
  2. Make sure Indexes is added to your Options directive under the Directory block for your DocumentRoot. In your case, your Options directive appears fine e.g.:

    Options Indexes FollowSymLinks
    
  3. Using the default dir_module block should be fine (you don't need to disable this) e.g.:

    <IfModule dir_module>
        DirectoryIndex index.htm
    </IfModule>
    
  4. Look for the Include directive for httpd-autoindex.conf at the end of httpd.conf and make sure it is uncommented:

    Include conf/extra/httpd-autoindex.conf
    
  5. In httpd-autoindex.conf, make sure:

    • Your IndexOptions directive has FancyIndexing listed e.g. IndexOptions FancyIndexing HTMLTable VersionSort.

    • Alias /icons/ is pointed at the correct directory for your icons e.g. Alias /icons/ "/path/to/Apache24/icons/"

    • The Directory block for your icon path uses the same path as Alias /icons/ e.g <Directory "/path/to/Apache24/icons/">

Once these steps are complete, restart the server and remove/rename any index files in the directories you want to show FancyIndexing in.

Example Results

ex. Normal Apache Indexing

No Fancy Indexing

ex. FancyIndex Apache Indexing

Fancy Indexing

  • Thanks, - your answer was a little dated (pre-2.4), but it was well put together, with helpful observations and good examples; so I was happy to give you 2 points (or would have done, if the site had allowed me to after casting the initial vote). – Y Treehugger Cymru May 12 '18 at 22:08
  • In order to avoid more chaos with the website's pernicky rules, I have added further responses to your answer below my original question (my apologies if this confuses things). – Y Treehugger Cymru May 12 '18 at 22:11
  • Your welcome and thank you. =) Regarding your amended question, those are definitely worthwhile observations. I honestly can't say I was aware that the Red Hat "gotcha" was even an issue... so that is a nice bit of information to have. Very much appreciated. =) – Anaksunaman May 13 '18 at 0:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.