Subpage not working after Digital Ocean Deployment

The root cause is most probably a default configuration setting of Apache webserver, namely the definition of the alias /icons/ which points to /usr/share/apache2/icons/.

The alias is set on a global level and thus affects all sites.

The background of this is that Apache comes with a set of icons i.e. for file types which can be used in directory listings out of the box. These icons are installed in /usr/share/apache2/icons/ and thus can be refered by <img src="/icons/blabla.gif" ... as it is the case when autoindexing directory listings.

When autoindexing and the accompanying IndexOptions directive are not used, the URL http[s]://my.domain.com/icons/ will show the “Forbidden” error and the following entry in the Apache error log:

AH01276: Cannot serve directory /usr/share/apache2/icons/: No matching DirectoryIndex (index.html,index.cgi,index.pl,index.php,index.xhtml,index.htm) found, and server-generated directory index forbidden by Options directive

The URL http[s]://my.domain.com/icons (note the missing slash at the end) will not be affected, as the alias only matches /icons/ and not /icons.

The solution to this problem depends on your access to the Apache configuration files. If you do not have access to these I think the only possible solution is indeed to avoid URL paths starting with /icons/ since as far as I know, mitigation in .htaccess only will not work.

If you do have access to the Apache configuration files, one of these actions will work:

  1. Do not use mod_alias at all. Of course, this is steamroller tactics as it will disable all kinds of Alias and Redirect... configuration directives.
  2. Disable the inclusion of the file /etc/apache2/mods-enabled/alias.conf. This file is activated together with mod_alias and contains the definition of the alias (and only this). It is not needed for mod_alias to work. However, removal will disable proper autoindexing features systemwide as the icons can not be found. On the other hand, the alias for icons could be enabled only at these virtual hosts where they are really needed.
  3. Contrariwise you can overwrite the alias with a Redirect "/icons/" "/icons" directive in your virtual host configuration for those sites where it should be disabled. This directive will take precedence over the alias and redirects requests starting with /icons/ to /icons where they will be handled by Kirby again.
3 Likes

Exactly what was happening, I didn’t know why but this was the error in the apache log. I put all favicons in /icons/ directory and kept getting 403 forbidden on it, while all of the others worked normally.

This should be some common knowledge. I wonder are there any other “forbidden” directory names…

Thanks for the clarification! :slight_smile: :+1: