Home / Apache and icons directory

Apache and icons directory

Default installations of Apache usually alias /icons to Apache’s icons directory which cannot be overridden in an .htaccess file. If you do not control the Apache configuration of a server, and for maximum compatibility, it is always best to never have an /icons directory at a website’s root level.

Example default configuration

On a Debian box, for example, the following is defined at /etc/apache2/mods-available/alias.conf:

Alias /icons/ "/usr/share/apache2/icons/"

If you control the server you could easily enough disable this alias, or change it to something else. The alias directive cannot be changed in a .htaccess file so if you do not control the server you will not be able to change it.

As I mentioned in the opening paragraph it’s better for compatibility purposes to assume you can never change this so if you have to move your website to another server you don’t have issues.

The solution

I ran into this issue the other day when I decided on a new website to put the icons I was using for some admin pages into a directory called /icons at the website’s root level. Of course, I ended up without the icons displaying and a bunch of 404 errors in my log file like this:

File does not exist: /usr/share/apache2/icons/myicon.png

The best solution is to either put your icons directory into a subdirectory, or give it a different name if it’s at the root level. In my case I moved it so it was a subdirectory of /images.