Apache and icons directoryApache and icons directory

Posted March 28th, 2010 in Apache

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.

Related posts:

Share or Bookmark

Share or Bookmark this page using the following services. You will need to have an account with the selected service in order to post links or bookmark this page.

Subscribe or Follow

Subscribe via RSS or email, or follow me on Facebook or Twitter below. The RSS icon takes you through to Feedburner where you can select the service or application to use.

Comments

blog comments powered by Disqus